From 369e2ede0169933bb8c6c393b01821541ca0e2bd Mon Sep 17 00:00:00 2001 From: ananyamk1 <84680895+ananyamk1@users.noreply.github.com> Date: Mon, 9 Nov 2026 01:15:53 -0600 Subject: [PATCH] test: add public health liveness contract test Refs #34 --- tests/roadmap/text/test_health_contract.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/roadmap/text/test_health_contract.py diff --git a/tests/roadmap/text/test_health_contract.py b/tests/roadmap/text/test_health_contract.py new file mode 100644 index 0000000..4b10fcc --- /dev/null +++ b/tests/roadmap/text/test_health_contract.py @@ -0,0 +1,20 @@ +"""Contract test for the public /health liveness endpoint (issue #34).""" + + +def test_health_is_public_and_cheap(client, mocker): + client.headers.pop("Authorization") + rate_limit_check = mocker.patch("app.services.rate_limit.check_rate_limit") + redis_ping = mocker.patch("app.services.rate_limit.r.ping") + provider_call = mocker.patch("app.services.risk.ask_deepseek") + assessment = mocker.patch("app.api.analyze.get_assessment") + + response = client.get("/health") + + assert "Authorization" not in response.request.headers + assert response.status_code == 200 + assert response.json() == {"status": "ok"} + + rate_limit_check.assert_not_called() + redis_ping.assert_not_called() + provider_call.assert_not_called() + assessment.assert_not_called()