import allure import pytest from httpx import HTTPStatusError from tests.e2e.conftest import MySession, e2e_settings @pytest.mark.integra class TestCrud: @pytest.mark.parametrize("email",[ ("test@d.d") ]) async def test_get_user_by_email_positive(self, email:str, auth_fixture:MySession)->None: with allure.step("Get user by email"): target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}" response = await auth_fixture.get(f"{target_url}/user/get_by_email",params={"email":email}) response.raise_for_status() response=response.json() with allure.step("Validate response"): assert response.get("email")==email assert "TEST_" in response.get("first_name") assert "TEST_" in response.get("last_name") assert "TEST_" in response.get("middle_name") assert response.get("direct_permissions")==[] assert response.get("group")==[] assert not response.get("hashed_password") or not response.get("plain_password") or not response.get("password") @pytest.mark.parametrize("email, expected_exception", [ ("test@test.test", HTTPStatusError), ("test", HTTPStatusError), ("@d", HTTPStatusError) ]) async def test_get_user_by_email_negative(self, email:str, expected_exception, auth_fixture:MySession)->None: with allure.step("Get user by email"), pytest.raises(expected_exception): target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}" response = await auth_fixture.get(f"{target_url}/user/get_by_email",params={"email":email}) response.raise_for_status()