1
1
import os
2
+ from typing import cast
2
3
3
4
import pytest
4
5
import pytest_asyncio
5
- from aiohttp import BasicAuth , ClientSession
6
+ from aiohttp import BasicAuth , ClientSession , web
6
7
from yarl import URL
7
8
8
9
from main import create_app as _create_app
9
10
11
+ from . import app_keys as ak
12
+
10
13
11
14
async def start_app (aiohttp_client ):
12
15
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 ]
14
17
sdk ._test_start_txid = - 1
15
18
16
19
return app
@@ -40,20 +43,18 @@ async def _request(self, method, path, *args, **kwargs):
40
43
@pytest_asyncio .fixture
41
44
async def aidbox (client ):
42
45
"""HTTP client for making requests to Aidbox"""
43
- app = client .server .app
46
+ app = cast ( web . Application , client .server .app )
44
47
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 ,
47
50
)
48
- session = AidboxSession (auth = basic_auth )
51
+ session = AidboxSession (auth = basic_auth , base_url = app [ ak . settings ]. APP_INIT_URL )
49
52
yield session
50
53
await session .close ()
51
54
52
55
53
56
@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 ):
57
58
resp = await aidbox .post (
58
59
"/$psql" ,
59
60
json = {"query" : "SELECT last_value from transaction_id_seq;" },
@@ -76,14 +77,14 @@ async def safe_db(aidbox, client):
76
77
77
78
@pytest .fixture ()
78
79
def sdk (client ):
79
- return client .server .app [ " sdk" ]
80
+ return cast ( web . Application , client .server .app )[ ak . sdk ]
80
81
81
82
82
83
@pytest .fixture ()
83
84
def aidbox_client (client ):
84
- return client .server .app [ " client" ]
85
+ return cast ( web . Application , client .server .app )[ ak . client ]
85
86
86
87
87
88
@pytest .fixture ()
88
89
def aidbox_db (client ):
89
- return client .server .app [ "db" ]
90
+ return cast ( web . Application , client .server .app )[ ak . db ]
0 commit comments