diff --git a/backend/model/tribe.py b/backend/model/tribe.py index b902b26..4b33183 100644 --- a/backend/model/tribe.py +++ b/backend/model/tribe.py @@ -23,5 +23,5 @@ class Tribe: def __eq__(self, other: object) -> bool: if isinstance(other, Tribe): - return self.name == other.name and self.level == other.level + return self.name == other.name return False diff --git a/tests/integration/test_orm.py b/tests/integration/test_orm.py index 2b57066..a137e8c 100644 --- a/tests/integration/test_orm.py +++ b/tests/integration/test_orm.py @@ -13,3 +13,30 @@ def test_tribes_mapper_can_load_tribe(session): (Tribe("tribe2", "1ST")), ] 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]