|
1 | 1 | import os |
| 2 | + |
| 3 | +os.environ["GOOGLE_MAPS_API_KEY"] = "invalid_google_maps_api_key_for_tests" |
| 4 | + |
2 | 5 | from typing import Any, AsyncGenerator, Callable |
3 | 6 | from unittest.mock import MagicMock, patch |
4 | 7 |
|
5 | 8 | import bcrypt |
6 | 9 | import googlemaps |
| 10 | +import pytest |
7 | 11 | import pytest_asyncio |
| 12 | +import src.modules # Ensure all modules are imported so their entities are registered # noqa: F401 |
8 | 13 | from httpx import ASGITransport, AsyncClient |
9 | | -from sqlalchemy.ext.asyncio import AsyncSession |
| 14 | +from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine |
10 | 15 | from src.core.authentication import StringRole |
11 | | -from src.core.database import get_session |
| 16 | +from src.core.database import EntityBase, get_session |
12 | 17 | from src.main import app |
13 | 18 | from src.modules.account.account_service import AccountService |
14 | 19 | from src.modules.complaint.complaint_service import ComplaintService |
|
24 | 29 | from test.modules.police.police_utils import PoliceTestUtils |
25 | 30 | from test.modules.student.student_utils import StudentTestUtils |
26 | 31 |
|
27 | | -os.environ["GOOGLE_MAPS_API_KEY"] = "invalid_google_maps_api_key_for_tests" |
28 | | - |
29 | | -import pytest |
30 | | -import src.modules # Ensure all modules are imported so their entities are registered # noqa: F401 |
31 | | -from sqlalchemy.ext.asyncio import async_sessionmaker, create_async_engine |
32 | | -from src.core.database import EntityBase |
33 | | - |
34 | 32 | DATABASE_URL = "sqlite+aiosqlite:///:memory:" |
35 | 33 |
|
36 | 34 | # =================================== Database ====================================== |
@@ -131,9 +129,11 @@ def student_service(test_session: AsyncSession): |
131 | 129 | return StudentService(session=test_session) |
132 | 130 |
|
133 | 131 |
|
134 | | -@pytest.fixture() |
135 | | -def mock_gmaps() -> MagicMock: |
136 | | - return MagicMock(spec=googlemaps.Client) |
| 132 | +@pytest.fixture(autouse=True) |
| 133 | +def mock_gmaps(): |
| 134 | + mock = MagicMock(spec=googlemaps.Client) |
| 135 | + with patch("googlemaps.Client", return_value=mock): |
| 136 | + yield mock |
137 | 137 |
|
138 | 138 |
|
139 | 139 | @pytest.fixture() |
|
0 commit comments