Feat: Tribe equality on name and add tests
This commit is contained in:
parent
723092c38f
commit
b4df4d6c09
@ -23,5 +23,5 @@ class Tribe:
|
|||||||
|
|
||||||
def __eq__(self, other: object) -> bool:
|
def __eq__(self, other: object) -> bool:
|
||||||
if isinstance(other, Tribe):
|
if isinstance(other, Tribe):
|
||||||
return self.name == other.name and self.level == other.level
|
return self.name == other.name
|
||||||
return False
|
return False
|
||||||
|
@ -13,3 +13,30 @@ def test_tribes_mapper_can_load_tribe(session):
|
|||||||
(Tribe("tribe2", "1ST")),
|
(Tribe("tribe2", "1ST")),
|
||||||
]
|
]
|
||||||
assert session.query(Tribe).all() == expected
|
assert session.query(Tribe).all() == expected
|
||||||
|
|
||||||
|
|
||||||
|
def test_tribe_mapper_can_save_tribe(session):
|
||||||
|
tribe_infos = ("tribe1", "2nd")
|
||||||
|
tribe = Tribe(*tribe_infos)
|
||||||
|
session.add(tribe)
|
||||||
|
|
||||||
|
rows = list(session.execute("SELECT name, level FROM 'tribes'"))
|
||||||
|
assert rows == []
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
rows = list(session.execute("SELECT name, level FROM 'tribes'"))
|
||||||
|
assert rows == [tribe_infos]
|
||||||
|
|
||||||
|
|
||||||
|
def test_tribe_mapper_can_save_and_load_tribe(session):
|
||||||
|
tribe_infos = ("tribe1", "2nd")
|
||||||
|
tribe = Tribe(*tribe_infos)
|
||||||
|
|
||||||
|
assert session.query(Tribe).all() == []
|
||||||
|
session.add(tribe)
|
||||||
|
|
||||||
|
assert session.query(Tribe).all() == [tribe]
|
||||||
|
session.commit()
|
||||||
|
|
||||||
|
assert session.query(Tribe).all() == [tribe]
|
||||||
|
Loading…
Reference in New Issue
Block a user