(summary) add minimal test suite for health endpoint

Based on cameldev's work, introduce basic tests to ensure the
health endpoint responds correctly.
This commit is contained in:
lebaudantoine
2026-03-17 22:08:00 +01:00
committed by aleb_the_flash
parent bfbfade99a
commit 83bd9c5ce3
6 changed files with 51 additions and 0 deletions
+7
View File
@@ -0,0 +1,7 @@
#!/usr/bin/env bash
source "$(dirname "${BASH_SOURCE[0]}")/_config.sh"
_dc_run \
app-summary-dev \
python -m pytest "$@"
+9
View File
@@ -21,8 +21,16 @@ dependencies = [
[project.optional-dependencies]
dev = [
"ruff==0.14.4",
"pytest==9.0.2",
"responses>=0.25.8",
]
[tool.pytest.ini_options]
markers = [
"api: Test the API",
]
testpaths = ["tests"]
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"
@@ -49,6 +57,7 @@ select = [
"T20", # flake8-print
"W", # pycodestyle warning
]
ignore= ["PLR2004"]
[tool.ruff.lint.per-file-ignores]
"tests/*" = [
+1
View File
@@ -0,0 +1 @@
"""Tests for the summary service."""
+1
View File
@@ -0,0 +1 @@
"""Tests for the API summary service."""
+21
View File
@@ -0,0 +1,21 @@
"""Integration tests for the health check endpoints."""
class TestHeartbeat:
"""Tests for the /__heartbeat__ endpoint."""
def test_returns_200(self, client):
"""The heartbeat endpoint responds with 200 OK without a token."""
response = client.get("/__heartbeat__")
assert response.status_code == 200
class TestLBHeartbeat:
"""Tests for the /__lbheartbeat__ endpoint."""
def test_returns_200(self, client):
"""The load-balancer heartbeat endpoint responds with 200 OK without a token."""
response = client.get("/__lbheartbeat__")
assert response.status_code == 200
+12
View File
@@ -0,0 +1,12 @@
"""Integration test configuration. Provides shared fixtures."""
import pytest
from fastapi.testclient import TestClient
from summary.main import app
@pytest.fixture()
def client():
"""Provide a FastAPI TestClient for integration tests."""
return TestClient(app)