From bde8822d3f7ffcd3e060391a261a0bf475b056f8 Mon Sep 17 00:00:00 2001 From: Murilo da Silva Pereira Date: Fri, 23 Oct 2026 10:18:10 -0300 Subject: [PATCH] Add behavior tests for the health and hello endpoints Line coverage was already 100%, but most behavior had no assertions. The new tests cover: - response bodies, the 64-character limit (counted in characters, not bytes) and unicode/emoji/special-character names - 422 error details, unknown and repeated query parameters - 404, 405 with the Allow header, and the trailing-slash redirect - the logging middleware: format, no query string, /healthz skipped, timing taken from perf_counter Co-Authored-By: Claude Opus 5.5 --- tests/test_main.py | 108 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index 63fa944..de58ec2 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,3 +1,7 @@ +import logging +import re +from types import SimpleNamespace + import pytest from fastapi.testclient import TestClient @@ -24,3 +28,107 @@ def test_hello(params, message): def test_hello_rejects_long_name(): response = client.get("/hello", params={"name": "a" * 65}) assert response.status_code == 422 + + +def test_healthz_corpo(): + response = client.get("/healthz") + assert response.json() == {"status": "ok"} + + +@pytest.mark.parametrize( + "name", + ["a" * 64, "a", "", "José", "日本語", "🚀", "a b&c=d", "