Feat: add update and delete tribe to services
This commit is contained in:
@@ -40,7 +40,7 @@ class FakeTribeRepository(AbstractRepository):
|
||||
try:
|
||||
self._tribes.pop(name)
|
||||
except KeyError:
|
||||
raise KeyError(f"The tribe {tribe} does not exists")
|
||||
raise TribeRepositoryError(f"The tribe {name} does not exists")
|
||||
|
||||
|
||||
class FakeStudentRepository(AbstractRepository):
|
||||
@@ -140,3 +140,26 @@ def test_update_tribe_fail_not_exists():
|
||||
)
|
||||
|
||||
assert conn.committed == False
|
||||
|
||||
|
||||
def test_delete_tribe():
|
||||
tribes = build_tribes(3)
|
||||
tribe_repo = FakeTribeRepository(tribes)
|
||||
conn = FakeConn()
|
||||
|
||||
tribe = tribes.pop()
|
||||
services.delete_tribe(name=tribe.name, tribe_repo=tribe_repo, conn=conn)
|
||||
|
||||
assert conn.committed == True
|
||||
assert set(tribe_repo.list()) == set(tribes)
|
||||
|
||||
|
||||
def test_delete_tribe_fail_not_exists():
|
||||
tribes = build_tribes(3)
|
||||
tribe_repo = FakeTribeRepository(tribes)
|
||||
conn = FakeConn()
|
||||
|
||||
with pytest.raises(TribeDosNotExists):
|
||||
services.delete_tribe(name="azerty", tribe_repo=tribe_repo, conn=conn)
|
||||
|
||||
assert conn.committed == False
|
||||
|
||||
Reference in New Issue
Block a user