mirror of
https://github.com/283375/arcaea-offline.git
synced 2025-07-01 12:16:26 +00:00
fix: adapt to new model and tests
- I actually forgot I wrote tests lol
This commit is contained in:
@ -5,13 +5,13 @@ Pack <> PackLocalized
|
||||
"""
|
||||
|
||||
from arcaea_offline.constants.enums import ArcaeaLanguage
|
||||
from arcaea_offline.database.models import ModelsV5Base, Pack, PackLocalized
|
||||
from arcaea_offline.database.models import ModelBase, Pack, PackLocalization
|
||||
|
||||
|
||||
class TestPackRelationships:
|
||||
@staticmethod
|
||||
def init_db(session):
|
||||
ModelsV5Base.metadata.create_all(session.bind)
|
||||
ModelBase.metadata.create_all(session.bind)
|
||||
|
||||
def test_localized_objects(self, db_session):
|
||||
self.init_db(db_session)
|
||||
@ -26,20 +26,16 @@ class TestPackRelationships:
|
||||
description=description_en,
|
||||
)
|
||||
|
||||
pkid_ja = 1
|
||||
description_ja = "普通のパートナー「∅」と一緒に、\n不人気フレームワーク「Arcaea Offline」より、\n一般的なデータベース・モデルを通過する。"
|
||||
pack_localized_ja = PackLocalized(
|
||||
pkid=pkid_ja,
|
||||
pack_localized_ja = PackLocalization(
|
||||
id=pack_id,
|
||||
lang=ArcaeaLanguage.JA.value,
|
||||
name=None,
|
||||
description=description_ja,
|
||||
)
|
||||
|
||||
pkid_zh_hans = 2
|
||||
description_zh_hans = "与平凡的「∅」一起,\n在没人用的「Arcaea Offline」框架里,\n一同探索随处可见的数据库模型。"
|
||||
pack_localized_zh_hans = PackLocalized(
|
||||
pkid=pkid_zh_hans,
|
||||
pack_localized_zh_hans = PackLocalization(
|
||||
id=pack_id,
|
||||
lang=ArcaeaLanguage.ZH_HANS.value,
|
||||
name=None,
|
||||
@ -49,11 +45,11 @@ class TestPackRelationships:
|
||||
db_session.add_all([pack, pack_localized_ja])
|
||||
db_session.commit()
|
||||
|
||||
assert len(pack.localized_objects) == len([pack_localized_ja])
|
||||
assert len(pack.localized_entries) == len([pack_localized_ja])
|
||||
|
||||
assert pack_localized_ja.parent.description == pack.description
|
||||
assert pack_localized_ja.pack.description == pack.description
|
||||
|
||||
# relationships should be viewonly
|
||||
# test back populates
|
||||
new_pack = Pack(
|
||||
id=f"{pack_id}_new",
|
||||
name="NEW",
|
||||
@ -61,9 +57,10 @@ class TestPackRelationships:
|
||||
)
|
||||
db_session.add(new_pack)
|
||||
|
||||
pack_localized_ja.parent = new_pack
|
||||
pack.localized_objects.append(pack_localized_zh_hans)
|
||||
pack_localized_ja.pack = new_pack
|
||||
pack.localized_entries.append(pack_localized_zh_hans)
|
||||
db_session.commit()
|
||||
|
||||
assert pack_localized_ja.parent == pack
|
||||
assert len(pack.localized_objects) == 1
|
||||
assert pack_localized_ja.pack.id == new_pack.id
|
||||
# TODO: this failes but why
|
||||
assert len(pack.localized_entries) == 2
|
||||
|
Reference in New Issue
Block a user