11import os
2+ from typing import cast
23
34import pytest
45import pytest_asyncio
5- from aiohttp import BasicAuth , ClientSession
6+ from aiohttp import BasicAuth , ClientSession , web
67from yarl import URL
78
89from main import create_app as _create_app
910
11+ from . import app_keys as ak
12+
1013
1114async def start_app (aiohttp_client ):
1215 app = await aiohttp_client (_create_app (), server_kwargs = {"host" : "0.0.0.0" , "port" : 8081 })
13- sdk = app .server .app [ " sdk" ]
16+ sdk = cast ( web . Application , app .server .app )[ ak . sdk ]
1417 sdk ._test_start_txid = - 1
1518
1619 return app
@@ -40,20 +43,18 @@ async def _request(self, method, path, *args, **kwargs):
4043@pytest_asyncio .fixture
4144async def aidbox (client ):
4245 """HTTP client for making requests to Aidbox"""
43- app = client .server .app
46+ app = cast ( web . Application , client .server .app )
4447 basic_auth = BasicAuth (
45- login = app [" settings" ].APP_INIT_CLIENT_ID ,
46- password = app [" settings" ].APP_INIT_CLIENT_SECRET ,
48+ login = app [ak . settings ].APP_INIT_CLIENT_ID ,
49+ password = app [ak . settings ].APP_INIT_CLIENT_SECRET ,
4750 )
48- session = AidboxSession (auth = basic_auth )
51+ session = AidboxSession (auth = basic_auth , base_url = app [ ak . settings ]. APP_INIT_URL )
4952 yield session
5053 await session .close ()
5154
5255
5356@pytest_asyncio .fixture
54- async def safe_db (aidbox , client ):
55- sdk = client .server .app ["sdk" ]
56-
57+ async def safe_db (aidbox , client , sdk ):
5758 resp = await aidbox .post (
5859 "/$psql" ,
5960 json = {"query" : "SELECT last_value from transaction_id_seq;" },
@@ -76,14 +77,14 @@ async def safe_db(aidbox, client):
7677
7778@pytest .fixture ()
7879def sdk (client ):
79- return client .server .app [ " sdk" ]
80+ return cast ( web . Application , client .server .app )[ ak . sdk ]
8081
8182
8283@pytest .fixture ()
8384def aidbox_client (client ):
84- return client .server .app [ " client" ]
85+ return cast ( web . Application , client .server .app )[ ak . client ]
8586
8687
8788@pytest .fixture ()
8889def aidbox_db (client ):
89- return client .server .app [ "db" ]
90+ return cast ( web . Application , client .server .app )[ ak . db ]
0 commit comments