Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Run python tests
run: |
poetry install --no-interaction
poetry run pytest
poetry run pytest --mypy --cov=src --cov-report=term --cov-fail-under=50

- name: Run container tests
run: |
Expand Down
10 changes: 10 additions & 0 deletions .idea/poetry.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions .idea/test-repo.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

124 changes: 123 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ hypercorn = {extras = ["uvloop"], version = "^0.17.3"}
[tool.poetry.group.dev.dependencies]
pytest = "^8.2.1"
pytest-cov = "^5.0.0"
pytest-mypy = "^0.10.3"
pytest-asyncio = "^0.23.8"
pre-commit = "^3.7.1"

[build-system]
Expand Down
5 changes: 3 additions & 2 deletions src/testrepo/app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import logging

from quart import Quart, Response, jsonify, make_response
from quart import Quart, jsonify, make_response
from quart.typing import ResponseTypes

from testrepo import __version__

Expand All @@ -11,7 +12,7 @@ def load() -> Quart:
app.logger.info("starting web application version %s", __version__)

@app.route("/")
async def health() -> Response:
async def health() -> ResponseTypes:
return await make_response(
jsonify({
"status": "pass",
Expand Down
17 changes: 17 additions & 0 deletions tests/test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

from testrepo.app import load


@pytest.mark.asyncio
async def test_health_route():
app = load()
test_client = app.test_client()
response = await test_client.get("/")
assert response.status_code == 200
json_data = await response.get_json()
assert json_data == {
"status": "pass",
"message": "flux capacitor is fluxing",
"version": "0.0.0"
}
16 changes: 14 additions & 2 deletions tests/test_repo.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
def test_repo():
assert True
import importlib.metadata
from unittest.mock import patch

import testrepo


def test_version_found():
with patch.object(importlib.metadata, "version", return_value="1.2.3"):
assert testrepo.version("test_package") == "1.2.3"


def test_version_not_found():
with patch.object(importlib.metadata, "version", side_effect=importlib.metadata.PackageNotFoundError):
assert testrepo.version("test_package") == "0.0.0"