File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 4
4
from starlette .routing import Mount , Route , Router
5
5
6
6
from common import AppConfig , application_init
7
+ from common .di_container import Container
7
8
from common .telemetry import instrument_third_party
8
9
from socketio_app .namespaces .chat import ChatNamespace
9
10
from socketio_app .web_routes import docs
15
16
16
17
def create_app (
17
18
test_config : Union [AppConfig , None ] = None ,
19
+ test_di_container : Union [Container , None ] = None ,
18
20
) -> Router :
19
21
_config = test_config or AppConfig ()
20
- application_init (_config )
22
+ application_init (_config , test_di_container )
21
23
22
24
# SocketIO App
23
25
sio = socketio .AsyncServer (async_mode = "asgi" )
Original file line number Diff line number Diff line change
1
+ from collections .abc import Iterator
2
+ from unittest .mock import patch
3
+
4
+ import pytest
5
+ from dependency_injector .providers import Object
6
+ from starlette .routing import Router
7
+
8
+ from common .di_container import Container
9
+ from socketio_app import create_app
10
+
11
+
12
+ @pytest .fixture (scope = "session" )
13
+ def test_di_container (test_config ) -> Container :
14
+ return Container (
15
+ config = Object (test_config ),
16
+ )
17
+
18
+
19
+ @pytest .fixture (scope = "session" )
20
+ def testapp (test_config , test_di_container ) -> Iterator [Router ]:
21
+ # We don't need the storage to test the HTTP app
22
+ with patch ("common.bootstrap.init_storage" , return_value = None ):
23
+ app = create_app (test_config = test_config , test_di_container = test_di_container )
24
+ yield app
You can’t perform that action at this time.
0 commit comments