-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
32 lines (24 loc) · 815 Bytes
/
config.py
File metadata and controls
32 lines (24 loc) · 815 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from unittest.mock import Mock
from dishka import Provider, Scope, make_container, provide
from fastapi.testclient import TestClient
from pytest import fixture
from api.app import create_app
from core.config import PrimaryService
class TestAppProvider(Provider):
def __init__(self, mock_service, scope=None, component=None):
super().__init__(scope, component)
self.mock_service = mock_service
@provide(scope=None)
def users_service(self) -> PrimaryService:
return self.mock_service
class TestBase:
@fixture
def client(self, users_service):
return TestClient(
create_app(
make_container(TestAppProvider(users_service, scope=Scope.REQUEST))
)
)
@fixture
def users_service(self):
return Mock()