Feat: using service does not require to know about domain
This commit is contained in:
parent
b8a769b96d
commit
a95ce91b29
@ -7,7 +7,8 @@ class TribeExists(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def add_tribe(tribe: Tribe, tribe_repo: AbstractRepository, conn):
|
def add_tribe(name: str, level: str, tribe_repo: AbstractRepository, conn):
|
||||||
|
tribe = Tribe(name=name, level=level)
|
||||||
try:
|
try:
|
||||||
tribe_repo.add(tribe)
|
tribe_repo.add(tribe)
|
||||||
except TribeRepositoryError:
|
except TribeRepositoryError:
|
||||||
|
@ -89,7 +89,9 @@ def test_add_tribe():
|
|||||||
tribe_repo = FakeTribeRepository()
|
tribe_repo = FakeTribeRepository()
|
||||||
tribe = build_tribes(1)[0]
|
tribe = build_tribes(1)[0]
|
||||||
conn = FakeConn()
|
conn = FakeConn()
|
||||||
services.add_tribe(tribe, tribe_repo, conn)
|
services.add_tribe(
|
||||||
|
name=tribe.name, level=tribe.level, tribe_repo=tribe_repo, conn=conn
|
||||||
|
)
|
||||||
|
|
||||||
assert conn.committed == True
|
assert conn.committed == True
|
||||||
assert tribe_repo.list() == [tribe]
|
assert tribe_repo.list() == [tribe]
|
||||||
@ -99,10 +101,14 @@ def test_add_tribe_fail_exists():
|
|||||||
tribe_repo = FakeTribeRepository()
|
tribe_repo = FakeTribeRepository()
|
||||||
tribe = build_tribes(1)[0]
|
tribe = build_tribes(1)[0]
|
||||||
conn = FakeConn()
|
conn = FakeConn()
|
||||||
services.add_tribe(tribe, tribe_repo, conn)
|
services.add_tribe(
|
||||||
|
name=tribe.name, level=tribe.level, tribe_repo=tribe_repo, conn=conn
|
||||||
|
)
|
||||||
conn.reset_commit()
|
conn.reset_commit()
|
||||||
|
|
||||||
with pytest.raises(TribeExists):
|
with pytest.raises(TribeExists):
|
||||||
services.add_tribe(tribe, tribe_repo, conn)
|
services.add_tribe(
|
||||||
|
name=tribe.name, level=tribe.level, tribe_repo=tribe_repo, conn=conn
|
||||||
|
)
|
||||||
|
|
||||||
assert conn.committed == False
|
assert conn.committed == False
|
||||||
|
Loading…
Reference in New Issue
Block a user