Feat: add update_tribe in service
This commit is contained in:
@@ -7,6 +7,10 @@ class TribeExists(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class TribeDosNotExists(Exception):
|
||||
pass
|
||||
|
||||
|
||||
def add_tribe(name: str, level: str, tribe_repo: AbstractRepository, conn):
|
||||
tribe = Tribe(name=name, level=level)
|
||||
try:
|
||||
@@ -15,3 +19,13 @@ def add_tribe(name: str, level: str, tribe_repo: AbstractRepository, conn):
|
||||
raise TribeExists(f"The tribe {tribe.name} already exists")
|
||||
conn.commit()
|
||||
return tribe
|
||||
|
||||
|
||||
def update_tribe(name: str, level: str, tribe_repo: AbstractRepository, conn):
|
||||
tribe = Tribe(name=name, level=level)
|
||||
try:
|
||||
tribe_repo.update(name=name, tribe=tribe)
|
||||
except TribeRepositoryError:
|
||||
raise TribeDosNotExists(f"The tribe {name} does not exists you can't update it")
|
||||
conn.commit()
|
||||
return tribe
|
||||
|
||||
Reference in New Issue
Block a user