removing boilerplate target url
This commit is contained in:
@@ -10,6 +10,10 @@ from tests.e2e.conftest import MySession, e2e_settings
|
|||||||
@pytest.mark.integra
|
@pytest.mark.integra
|
||||||
class TestCrud:
|
class TestCrud:
|
||||||
|
|
||||||
|
async def _target_url(self):
|
||||||
|
return f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("test_user_fixture", [(["admin"], ["admin_group"])], indirect=True)
|
@pytest.mark.parametrize("test_user_fixture", [(["admin"], ["admin_group"])], indirect=True)
|
||||||
async def test_get_user_by_email_positive(self,test_user_fixture)->None:
|
async def test_get_user_by_email_positive(self,test_user_fixture)->None:
|
||||||
|
|
||||||
@@ -19,7 +23,7 @@ class TestCrud:
|
|||||||
|
|
||||||
email = new_user_record.get("email") #get email from the fixture in yield sector
|
email = new_user_record.get("email") #get email from the fixture in yield sector
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
response = await session.get(f"{target_url}/user/get_by_email",params={"email":email})
|
response = await session.get(f"{target_url}/user/get_by_email",params={"email":email})
|
||||||
response.raise_for_status()
|
response.raise_for_status()
|
||||||
response=response.json()
|
response=response.json()
|
||||||
@@ -43,7 +47,7 @@ class TestCrud:
|
|||||||
async def test_get_user_by_email_negative(self, email:str, expected_status:int, auth_fixture:MySession)->None:
|
async def test_get_user_by_email_negative(self, email:str, expected_status:int, auth_fixture:MySession)->None:
|
||||||
|
|
||||||
with allure.step("Get user by email"):
|
with allure.step("Get user by email"):
|
||||||
target_url = f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with pytest.raises(HTTPStatusError) as exc_info:
|
with pytest.raises(HTTPStatusError) as exc_info:
|
||||||
response = await auth_fixture.get(f"{target_url}/user/get_by_email", params={"email": email})
|
response = await auth_fixture.get(f"{target_url}/user/get_by_email", params={"email": email})
|
||||||
@@ -73,7 +77,7 @@ class TestCrud:
|
|||||||
|
|
||||||
with allure.step("Setting target_url"):
|
with allure.step("Setting target_url"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with allure.step("Create new test user and check for the new user"):
|
with allure.step("Create new test user and check for the new user"):
|
||||||
|
|
||||||
@@ -128,7 +132,7 @@ class TestCrud:
|
|||||||
with allure.step("Preparing data to create new user negative"):
|
with allure.step("Preparing data to create new user negative"):
|
||||||
|
|
||||||
user_created=False
|
user_created=False
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with allure.step("Create new test user and check for the new user"):
|
with allure.step("Create new test user and check for the new user"):
|
||||||
@@ -165,7 +169,7 @@ class TestCrud:
|
|||||||
async def test_user_create_delete_soft_positive(self, new_user_record:dict, auth_fixture:MySession)->None:
|
async def test_user_create_delete_soft_positive(self, new_user_record:dict, auth_fixture:MySession)->None:
|
||||||
with allure.step("Setting target_url"):
|
with allure.step("Setting target_url"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with allure.step("Create new test user and check for the new user"):
|
with allure.step("Create new test user and check for the new user"):
|
||||||
|
|
||||||
@@ -194,7 +198,7 @@ class TestCrud:
|
|||||||
|
|
||||||
with allure.step("Delete user soft"):
|
with allure.step("Delete user soft"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with pytest.raises(HTTPStatusError) as exc_info:
|
with pytest.raises(HTTPStatusError) as exc_info:
|
||||||
|
|
||||||
@@ -211,7 +215,7 @@ class TestCrud:
|
|||||||
|
|
||||||
with allure.step("Delete user hard"):
|
with allure.step("Delete user hard"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with pytest.raises(HTTPStatusError) as exc_info:
|
with pytest.raises(HTTPStatusError) as exc_info:
|
||||||
|
|
||||||
@@ -234,7 +238,7 @@ class TestCrud:
|
|||||||
|
|
||||||
with allure.step("Setting target_url"):
|
with allure.step("Setting target_url"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with allure.step("Update user"):
|
with allure.step("Update user"):
|
||||||
response= await session.patch(f"{target_url}/user/patch_user", json=user_record_to_update, params={"email":new_user_record["email"]})
|
response= await session.patch(f"{target_url}/user/patch_user", json=user_record_to_update, params={"email":new_user_record["email"]})
|
||||||
@@ -273,7 +277,7 @@ class TestCrud:
|
|||||||
|
|
||||||
with allure.step("Setting target_url"):
|
with allure.step("Setting target_url"):
|
||||||
|
|
||||||
target_url=f"http://{e2e_settings.HOST}:{e2e_settings.PORT}"
|
target_url=await self._target_url()
|
||||||
|
|
||||||
with allure.step("Update user"), pytest.raises(expected_exception) as exc_info:
|
with allure.step("Update user"), pytest.raises(expected_exception) as exc_info:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user