diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index 287ce4d..ddc861b 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -39,6 +39,13 @@ async def auth_client() -> APIClient: await auth_client_.close() +@pytest.fixture(scope="session") +async def another_auth_client() -> APIClient: + auth_client_ = create_auth_client(user_email="another@gmail.com") + yield auth_client_ + await auth_client_.close() + + @pytest.fixture def settings() -> Test: return settings_ diff --git a/tests/functional/testlib.py b/tests/functional/testlib.py index cc4d0a9..9ecdd30 100644 --- a/tests/functional/testlib.py +++ b/tests/functional/testlib.py @@ -31,13 +31,16 @@ class APIClient(ClientSession): def __init__( self, base_url: str | None = settings.SERVER_BASE_URL, - use_authorization: bool | None = False, + use_authorization: bool | None = False, user_email: str | None = None, *args, **kwargs, ): super().__init__(base_url, *args, **kwargs) self.base_url = base_url self.use_authorization = use_authorization self.auth_url = settings.NETFLIX_AUTH_BASE_URL + if user_email is None: + user_email = "test@gmail.com" + self.user_email = user_email async def _request(self, method, url, *args, **kwargs): headers = kwargs.pop("headers", {}) @@ -102,7 +105,7 @@ async def get_access_token(self) -> str: return await self._get_access_token() async def _get_access_token(self) -> str: - body = {"email": "test@gmail.com", "password": "pass"} + body = {"email": self.user_email, "password": "pass"} async with aiohttp.ClientSession() as session: async with session.post(urljoin(self.auth_url, "/api/v1/auth/register"), data=body): ... @@ -118,8 +121,8 @@ def create_anon_client() -> APIClient: return APIClient(base_url=settings.CLIENT_BASE_URL) -def create_auth_client() -> APIClient: - return APIClient(base_url=settings.CLIENT_BASE_URL, use_authorization=True) +def create_auth_client(user_email: str | None = None) -> APIClient: + return APIClient(base_url=settings.CLIENT_BASE_URL, use_authorization=True, user_email=user_email) async def run_redis_migrations() -> None: