Feat: add sad path test and exceptions for update and delete
This commit is contained in:
@@ -28,6 +28,13 @@ class TribeSQLiteRepository(AbstractRepository):
|
||||
)
|
||||
|
||||
def update(self, name: str, tribe: Tribe) -> None:
|
||||
tribes = self.list()
|
||||
|
||||
if name not in map(lambda x: x.name, tribes):
|
||||
raise TribeRepositoryError(
|
||||
f"The tribe {name} doesn't exists. Can't update it"
|
||||
)
|
||||
|
||||
self.conn.execute(
|
||||
"""
|
||||
UPDATE tribes SET name=:newname, level=:newlevel WHERE name=:name
|
||||
@@ -66,6 +73,12 @@ class TribeSQLiteRepository(AbstractRepository):
|
||||
return [Tribe(*r) for r in rows]
|
||||
|
||||
def delete(self, tribe: Tribe) -> None:
|
||||
tribes = self.list()
|
||||
if tribe.name not in map(lambda x: x.name, tribes):
|
||||
raise TribeRepositoryError(
|
||||
f"The tribe {tribe.name} doesn't exists. Can't delete it."
|
||||
)
|
||||
|
||||
self.conn.execute(
|
||||
"""
|
||||
DELETE FROM tribes WHERE name=:name
|
||||
|
Reference in New Issue
Block a user