mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-07-01 12:16:26 +00:00
refactor: arcsong database importer & arcsong json exporter
This commit is contained in:
45
tests/external/importers/test_arcsong.py
vendored
Normal file
45
tests/external/importers/test_arcsong.py
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
import sqlite3
|
||||
|
||||
import tests.resources
|
||||
from arcaea_offline.constants.enums.arcaea import ArcaeaRatingClass
|
||||
from arcaea_offline.database.models.v5 import ChartInfo
|
||||
from arcaea_offline.external.importers.arcsong import (
|
||||
ArcsongDatabaseImporter,
|
||||
)
|
||||
|
||||
db = sqlite3.connect(":memory:")
|
||||
db.executescript(
|
||||
tests.resources.get_resource("arcsong.sql").read_text(encoding="utf-8")
|
||||
)
|
||||
|
||||
|
||||
class TestArcsongDatabaseImporter:
|
||||
def test_parse(self):
|
||||
items = ArcsongDatabaseImporter.parse(db)
|
||||
|
||||
assert all(isinstance(item, ChartInfo) for item in items)
|
||||
assert len(items) == 3
|
||||
|
||||
base1_pst = next(
|
||||
it
|
||||
for it in items
|
||||
if it.song_id == "base1" and it.rating_class is ArcaeaRatingClass.PAST
|
||||
)
|
||||
assert base1_pst.constant == 30
|
||||
assert base1_pst.notes == 500
|
||||
|
||||
base1_prs = next(
|
||||
it
|
||||
for it in items
|
||||
if it.song_id == "base1" and it.rating_class is ArcaeaRatingClass.PRESENT
|
||||
)
|
||||
assert base1_prs.constant == 60
|
||||
assert base1_prs.notes == 700
|
||||
|
||||
base1_ftr = next(
|
||||
it
|
||||
for it in items
|
||||
if it.song_id == "base1" and it.rating_class is ArcaeaRatingClass.FUTURE
|
||||
)
|
||||
assert base1_ftr.constant == 90
|
||||
assert base1_ftr.notes == 1000
|
Reference in New Issue
Block a user