all the remain tests
This commit is contained in:
@@ -44,5 +44,60 @@ class TestCrud:
|
||||
|
||||
await crud_service.get_user_by_email(email)
|
||||
|
||||
if expected_exception is HTTPException:
|
||||
assert exc_info.value.status_code==expected_status
|
||||
|
||||
@pytest.mark.parametrize("user_data",[
|
||||
pytest.param(SimpleNamespace(first_name="test",last_name="test",middle_name="test",email="d@d.d",direct_permissions=[],group=[],status=True),id="Get_user_by_email_positive")
|
||||
])
|
||||
async def test_delete_user_soft_positive(self, monkeypatch, user_data:SimpleNamespace, crud_service:CrudService)->None:
|
||||
|
||||
with allure.step("Patching functions"):
|
||||
monkeypatch.setattr(crud_service.crud_db_actions, "delete_user_soft",AsyncMock(return_value=True))
|
||||
|
||||
with allure.step("Test get_by_email"):
|
||||
test_result = await crud_service.delete_user_soft(user_data.email)
|
||||
|
||||
assert test_result == True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("email, expected_exception, expected_status",[
|
||||
pytest.param("Wrong_email", HTTPException, 404,id="Wrong_email"),
|
||||
pytest.param("",HTTPException, 404,id="Empty_email"),
|
||||
])
|
||||
async def test_delete_user_soft_negative(self, email, crud_service:CrudService, expected_exception, expected_status:int)->None:
|
||||
|
||||
with allure.step("Test get_by_email"), pytest.raises(expected_exception) as exc_info:
|
||||
|
||||
await crud_service.delete_user_soft(email)
|
||||
|
||||
if expected_exception is HTTPException:
|
||||
assert exc_info.value.status_code==expected_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize("user_data",[
|
||||
pytest.param(SimpleNamespace(first_name="test",last_name="test",middle_name="test",email="d@d.d",direct_permissions=[],group=[],status=True),id="Get_user_by_email_positive")
|
||||
])
|
||||
async def test_delete_user_hard_positive(self, monkeypatch, user_data:SimpleNamespace, crud_service:CrudService)->None:
|
||||
|
||||
with allure.step("Patching functions"):
|
||||
monkeypatch.setattr(crud_service.crud_db_actions, "delete_user_hard",AsyncMock(return_value=True))
|
||||
|
||||
with allure.step("Test get_by_email"):
|
||||
test_result = await crud_service.delete_user_hard(user_data.email, "current_user")
|
||||
|
||||
assert test_result==True
|
||||
|
||||
|
||||
@pytest.mark.parametrize("email, expected_exception, expected_status",[
|
||||
pytest.param("Wrong_email", HTTPException, 404,id="Wrong_email"),
|
||||
pytest.param("",HTTPException, 404,id="Empty_email"),
|
||||
])
|
||||
async def test_delete_user_hard_negative(self, email, crud_service:CrudService, expected_exception, expected_status:int)->None:
|
||||
|
||||
with allure.step("Test get_by_email"), pytest.raises(expected_exception) as exc_info:
|
||||
|
||||
await crud_service.delete_user_hard(email, "current_user")
|
||||
|
||||
if expected_exception is HTTPException:
|
||||
assert exc_info.value.status_code==expected_status
|
||||
Reference in New Issue
Block a user