File tree 2 files changed +12
-16
lines changed
2 files changed +12
-16
lines changed Original file line number Diff line number Diff line change 1
1
import logging
2
2
import typing
3
3
4
+ import modern_di_litestar
4
5
import pytest
5
6
from httpx import ASGITransport , AsyncClient
6
7
from sqlalchemy .ext .asyncio import AsyncSession
7
8
8
9
from app import ioc
9
- from app .application import AppBuilder
10
+ from app .application import application
10
11
11
12
12
13
logger = logging .getLogger (__name__ )
13
14
14
15
15
16
@pytest .fixture
16
- def app_builder () -> AppBuilder :
17
- return AppBuilder ()
18
-
19
-
20
- @pytest .fixture
21
- async def client (app_builder : AppBuilder ) -> typing .AsyncIterator [AsyncClient ]:
17
+ async def client () -> typing .AsyncIterator [AsyncClient ]:
22
18
async with AsyncClient (
23
- transport = ASGITransport (app = app_builder . app ), # type: ignore[arg-type]
19
+ transport = ASGITransport (app = application ), # type: ignore[arg-type]
24
20
base_url = "http://test" ,
25
21
) as client :
26
22
yield client
27
23
28
24
29
25
@pytest .fixture (autouse = True )
30
- async def db_session (app_builder : AppBuilder ) -> typing .AsyncIterator [AsyncSession ]:
31
- async with app_builder . di_container as di_container :
26
+ async def db_session () -> typing .AsyncIterator [AsyncSession ]:
27
+ async with modern_di_litestar . fetch_di_container ( application ) as di_container :
32
28
engine = await ioc .Dependencies .database_engine .async_resolve (di_container )
33
29
connection = await engine .connect ()
34
30
transaction = await connection .begin ()
You can’t perform that action at this time.
0 commit comments