e2e tests 0.1

This commit is contained in:
2026-08-17 11:42:12 +03:00
parent 4486f62e17
commit 0a4a21f2e7
10 changed files with 206 additions and 22 deletions
+20 -7
View File
@@ -12,6 +12,14 @@ class CrudService:
self.hash_service=HashService()
async def _plain_to_hash(self, user_data:dict)->dict:
user_data["hashed_password"]=user_data.pop("plain_password")
user_data["hashed_password"]=self.hash_service.plain_to_hash(user_data["hashed_password"])
return user_data
async def get_user_by_email(self, email:str)->UserOut:
user_entity=await self.crud_db_actions.get_user_by_email(email)
@@ -25,8 +33,7 @@ class CrudService:
user_data=UserCreate.model_dump(data)
user_data["hashed_password"]=user_data.pop("plain_password")
user_data["hashed_password"]=self.hash_service.plain_to_hash(user_data["hashed_password"])
user_data=await self._plain_to_hash(user_data)
user_entity=await self.crud_db_actions.create_user(user_data)
@@ -35,14 +42,21 @@ class CrudService:
return UserOut.model_validate(user_entity)
async def delete_user(self, email:str)->bool:
async def delete_user_soft(self, email:str)->bool:
user_entity=await self.crud_db_actions.delete_user(email)
user_entity=await self.crud_db_actions.delete_user_soft(email)
if not user_entity:
raise self.errors.not_found_error(detail="User not found")
return user_entity
async def delete_user_hard(self, email:str, current_user:UserOut)->bool:
user_entity=await self.crud_db_actions.delete_user_hard(email)
if not user_entity:
raise self.errors.not_found_error(detail="User not found")
return user_entity
async def update_user(self, email:str, data:UserUpdate)->UserOut:
@@ -52,10 +66,9 @@ class CrudService:
raise self.errors.bad_request_error(detail="User info to update can not be empty")
if user_data.get("plain_password"):
user_data["hashed_password"]=user_data.pop("plain_password")
user_data["hashed_password"]=self.hash_service.plain_to_hash(user_data["hashed_password"])
user_data=await self._plain_to_hash(user_data)
user_entity=await self.crud_db_actions.update_user(email, user_data)
user_entity=await self.crud_db_actions.update_user_partially(email, user_data)
if not user_entity:
raise self.errors.not_found_error(detail="User not found")