-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/sqlite repo #71
base: main
Are you sure you want to change the base?
Changes from 31 commits
fb8da82
dbf8df1
bfa02f9
d5ff73a
a55413c
e288445
d1c733f
ad6805e
b296d89
e99d741
59fbde7
4f24bd9
ef85176
3d3ff7c
962a1da
916defe
22e14e3
00d5884
90cb943
a180a72
a7d58c9
5d79824
c576c43
fca13b0
c8f23f9
39bbd27
5ddf9ad
3d15a1f
87265fd
fbb2c0a
0dd37fb
a6f45ed
938b62f
210d0c6
e19185b
71f5c43
b98428a
4354017
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
from blacksheep import Content, Response | ||
|
||
|
||
@pytest.mark.integration | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (testing): Changed test marker from integration to api Ensure that this change in test categorization is intentional and consistent with your testing strategy. Update any test runners or CI/CD pipelines that might rely on these markers. |
||
@pytest.mark.api | ||
@pytest.mark.usefixtures("client") | ||
class TestGeolocationAPI: | ||
async def test_location_query_endpoint(self, client): | ||
|
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -1,13 +1,12 @@ | ||||
from collections.abc import Callable | ||||
from contextlib import AsyncExitStack | ||||
from typing import List | ||||
import pytest | ||||
import unittest | ||||
import random | ||||
|
||||
|
||||
from rodi import Container, ContainerProtocol | ||||
from xcov19.app.database import start_db_session | ||||
from xcov19.tests.data.seed_db import seed_data | ||||
from xcov19.tests.start_server import start_test_database | ||||
from xcov19.tests.start_server import setUpTestDatabase | ||||
from xcov19.domain.models.provider import ( | ||||
Contact, | ||||
FacilityEstablishment, | ||||
|
@@ -24,9 +23,6 @@ | |||
|
||||
|
||||
from xcov19.utils.mixins import InterfaceProtocolCheckMixin | ||||
|
||||
import random | ||||
|
||||
from sqlmodel.ext.asyncio.session import AsyncSession as AsyncSessionWrapper | ||||
|
||||
|
||||
|
@@ -201,37 +197,44 @@ class GeoLocationServiceSqlRepoDBTest(unittest.IsolatedAsyncioTestCase): | |||
3. patient_query_lookup_svc is configured to call sqlite repository. | ||||
""" | ||||
|
||||
@pytest.fixture(autouse=True) | ||||
def autouse( | ||||
self, | ||||
dummy_geolocation_query_json: LocationQueryJSON, | ||||
dummy_reverse_geo_lookup_svc: Callable[[LocationQueryJSON], dict], | ||||
): | ||||
self.dummy_geolocation_query_json = dummy_geolocation_query_json | ||||
self.dummy_reverse_geo_lookup_svc = dummy_reverse_geo_lookup_svc | ||||
|
||||
async def asyncSetUp(self) -> None: | ||||
self._stack = AsyncExitStack() | ||||
container: ContainerProtocol = Container() | ||||
await start_test_database(container) | ||||
self._session = await self._stack.enter_async_context( | ||||
start_db_session(container) | ||||
) | ||||
if not isinstance(self._session, AsyncSessionWrapper): | ||||
raise RuntimeError(f"{self._session} is not a AsyncSessionWrapper value.") | ||||
self._test_db = setUpTestDatabase() | ||||
await self._test_db.setup_test_database() | ||||
self._session = await self._test_db.start_async_session() | ||||
assert isinstance(self._session, AsyncSessionWrapper) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Improved test database setup The new setup is more concise and uses a dedicated class for database setup. Consider adding error handling for the case where the session is not an AsyncSessionWrapper.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sourcery-ai It is implemented in this file:
|
||||
await seed_data(self._session) | ||||
await super().asyncSetUp() | ||||
|
||||
async def asyncTearDown(self) -> None: | ||||
print("async closing test server db session closing.") | ||||
await self._session.commit() | ||||
await self._stack.aclose() | ||||
print("async test server closing.") | ||||
await self._test_db.aclose() | ||||
await super().asyncTearDown() | ||||
|
||||
def _patient_query_lookup_svc_using_repo( | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. question (testing): Changed return type of _patient_query_lookup_svc_using_repo The return type has changed from a Callable to a List[FacilitiesResult]. Ensure that this change is intentional and that it doesn't break any existing tests or functionality. |
||||
self, address: Address, query: LocationQueryJSON | ||||
) -> Callable[[Address, LocationQueryJSON], List[FacilitiesResult]]: ... | ||||
) -> List[FacilitiesResult]: | ||||
# TODO: Implement a patient query lookup service | ||||
# that returns type List[FacilitiesResult] | ||||
... | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (testing): Implement the _patient_query_lookup_svc_using_repo method This method is currently a stub. Implement it to return a List[FacilitiesResult] as indicated in the TODO comment. This is crucial for testing the patient query lookup functionality. |
||||
|
||||
async def test_fetch_facilities(self): | ||||
# TODO Implement test_fetch_facilities like this: | ||||
# providers = await GeolocationQueryService.fetch_facilities( | ||||
# dummy_reverse_geo_lookup_svc, | ||||
# dummy_geolocation_query_json, | ||||
# self._patient_query_lookup_svc_using_repo | ||||
# ) | ||||
... | ||||
providers = await GeolocationQueryService.fetch_facilities( | ||||
self.dummy_reverse_geo_lookup_svc, | ||||
self.dummy_geolocation_query_json, | ||||
self._patient_query_lookup_svc_using_repo, | ||||
) | ||||
assert providers | ||||
self.assertIsInstance(providers, list) | ||||
self.assertIs(len(providers), 1) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Implemented test_fetch_facilities Good implementation of the TODO. Consider adding more assertions to check the content of the returned providers, not just the length and type.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Good implementation of test_fetch_facilities The test now properly calls GeolocationQueryService.fetch_facilities and asserts the result. Consider adding more specific assertions about the content of the returned providers.
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("dummy_geolocation_query_json", "dummy_reverse_geo_lookup_svc") | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Good refactoring of test database setup
The new setUpTestDatabase class improves the organization of test database setup and teardown. Consider adding more error handling and logging to improve debugging of test setup issues.