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
|
||||
|
||||
|
||||
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:
|
||||
tribe_repo.add(tribe)
|
||||
except TribeRepositoryError:
|
||||
|
@ -89,7 +89,9 @@ def test_add_tribe():
|
||||
tribe_repo = FakeTribeRepository()
|
||||
tribe = build_tribes(1)[0]
|
||||
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 tribe_repo.list() == [tribe]
|
||||
@ -99,10 +101,14 @@ def test_add_tribe_fail_exists():
|
||||
tribe_repo = FakeTribeRepository()
|
||||
tribe = build_tribes(1)[0]
|
||||
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()
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user