This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
from collections.abc import Iterator
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
|
||||
from dependencies import get_session
|
||||
from main import app
|
||||
from tests.fakes import FakeSession
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def fake_session() -> FakeSession:
|
||||
return FakeSession()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def client(fake_session: FakeSession) -> Iterator[TestClient]:
|
||||
def override_get_session() -> Iterator[FakeSession]:
|
||||
yield fake_session
|
||||
|
||||
app.dependency_overrides[get_session] = override_get_session
|
||||
|
||||
with TestClient(app) as test_client:
|
||||
yield test_client
|
||||
|
||||
app.dependency_overrides.clear()
|
||||
Reference in New Issue
Block a user