-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/sqlite repo: Identify type signature and annotations for inte…
…rface and sqlite implementation (#66) Prepares testing support for #26 - adds support for test markers - `make test` works. added test-integration marker and is currently WIP. - refactored unit tests to have dummy functions move to conftest. fix their type annotaitons. added e2e api testing support in start_server and conftest. added unit test configuration setup in pyproject.
- Loading branch information
Showing
11 changed files
with
226 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!/bin/bash | ||
|
||
poetry run python3 -m xcov19.dev | ||
APP_ENV=dev APP_DB_ENGINE_URL="sqlite+aiosqlite:///xcov19.db" poetry run python3 -m xcov19.dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from collections.abc import AsyncGenerator | ||
from xcov19.app.main import app | ||
from blacksheep import Application | ||
|
||
|
||
async def start_server() -> AsyncGenerator[Application, None]: | ||
"""Start a test server for automated testing.""" | ||
try: | ||
await app.start() | ||
yield app | ||
finally: | ||
if app.started: | ||
await app.stop() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import json | ||
import pytest | ||
from xcov19.dto import LocationQueryJSON, GeoLocation, AnonymousId, QueryId | ||
from blacksheep import Content, Response | ||
|
||
|
||
@pytest.mark.integration | ||
@pytest.mark.usefixtures("client") | ||
class TestGeolocationAPI: | ||
async def test_location_query_endpoint(self, client): | ||
# Prepare the request payload | ||
location_query = LocationQueryJSON( | ||
location=GeoLocation(lat=0, lng=0), | ||
cust_id=AnonymousId(cust_id="test_cust_id"), | ||
query_id=QueryId(query_id="test_query_id"), | ||
) | ||
|
||
# Send a POST request to the /geo endpoint | ||
query = location_query.model_dump(round_trip=True) | ||
binary_data = json.dumps(query).encode("utf-8") | ||
print("binary data", binary_data, type(binary_data)) | ||
response: Response = await client.post( | ||
"/geo", | ||
content=Content(b"application/json", binary_data), | ||
# Add the required header | ||
headers={ | ||
"X-Origin-Match-Header": "secret", | ||
}, | ||
) | ||
|
||
# The current implementation returns ok(), which is null in JSON | ||
# response_text = await response.text() | ||
# assert response_text.lower() == "resource not found" | ||
# Assert the response | ||
assert response.content_type() == b"text/plain; charset=utf-8" | ||
# assert response.content == b'' | ||
assert response.status == 200 |
Oops, something went wrong.