Feat: add update_tribe in service
This commit is contained in:
@@ -6,7 +6,7 @@ from backend.repository.abstract_repository import AbstractRepository
|
||||
from backend.repository.student_sqlite_repository import StudentRepositoryError
|
||||
from backend.repository.tribe_sqlite_repository import TribeRepositoryError
|
||||
from backend.service import services
|
||||
from backend.service.services import TribeExists
|
||||
from backend.service.services import TribeDosNotExists, TribeExists
|
||||
from tests.model.fakes import build_tribes
|
||||
|
||||
|
||||
@@ -112,3 +112,31 @@ def test_add_tribe_fail_exists():
|
||||
)
|
||||
|
||||
assert conn.committed == False
|
||||
|
||||
|
||||
def test_update_tribe():
|
||||
tribes = build_tribes(3)
|
||||
tribe_repo = FakeTribeRepository(tribes)
|
||||
conn = FakeConn()
|
||||
|
||||
other_level = "iouiouiou"
|
||||
tribes[0].level = other_level
|
||||
services.update_tribe(
|
||||
name=tribes[0].name, level=other_level, tribe_repo=tribe_repo, conn=conn
|
||||
)
|
||||
|
||||
assert conn.committed == True
|
||||
assert set(tribe_repo.list()) == set(tribes)
|
||||
|
||||
|
||||
def test_update_tribe_fail_not_exists():
|
||||
tribes = build_tribes(3)
|
||||
tribe_repo = FakeTribeRepository(tribes)
|
||||
conn = FakeConn()
|
||||
|
||||
with pytest.raises(TribeDosNotExists):
|
||||
services.update_tribe(
|
||||
name="azerty", level="jkl", tribe_repo=tribe_repo, conn=conn
|
||||
)
|
||||
|
||||
assert conn.committed == False
|
||||
|
||||
Reference in New Issue
Block a user