fix: use sync fixtures for E2E client
This commit is contained in:
parent
034a2e4775
commit
3fbf12163a
@ -37,33 +37,42 @@ def require_credentials(kwork_credentials):
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
async def client(require_credentials):
|
||||
def client(require_credentials):
|
||||
"""
|
||||
E2E клиент для всех тестов.
|
||||
|
||||
Авторизуется один раз и переиспользуется во всех тестах сессии.
|
||||
"""
|
||||
client = await KworkClient.login(
|
||||
username=require_credentials["username"],
|
||||
password=require_credentials["password"],
|
||||
)
|
||||
import asyncio
|
||||
|
||||
async def login():
|
||||
return await KworkClient.login(
|
||||
username=require_credentials["username"],
|
||||
password=require_credentials["password"],
|
||||
)
|
||||
|
||||
client = asyncio.run(login())
|
||||
yield client
|
||||
await client.close()
|
||||
asyncio.run(client.close())
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
async def catalog_kwork_id(client):
|
||||
def catalog_kwork_id(client):
|
||||
"""
|
||||
Получить ID первого кворка из каталога для тестов.
|
||||
|
||||
Переиспользуется во всех тестах сессии.
|
||||
"""
|
||||
catalog = await client.catalog.get_list(page=1)
|
||||
if len(catalog.kworks) > 0:
|
||||
return catalog.kworks[0].id
|
||||
else:
|
||||
import asyncio
|
||||
|
||||
async def get_first_kwork():
|
||||
catalog = await client.catalog.get_list(page=1)
|
||||
if len(catalog.kworks) > 0:
|
||||
return catalog.kworks[0].id
|
||||
return None
|
||||
|
||||
return asyncio.run(get_first_kwork())
|
||||
|
||||
|
||||
@pytest.fixture(scope="function")
|
||||
def slowmo(request):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user