From 7ed2cca15ffe48ba5c1d899c87c25d5652bf22ff Mon Sep 17 00:00:00 2001 From: Dotty Dotter Date: Fri, 10 Apr 2026 20:09:34 +0200 Subject: [PATCH] Tests: 8 Endpoint-Smoke-Tests (queue, auth, programme, health) --- tests/test_endpoints_smoke.py | 79 +++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 tests/test_endpoints_smoke.py diff --git a/tests/test_endpoints_smoke.py b/tests/test_endpoints_smoke.py new file mode 100644 index 0000000..02214a1 --- /dev/null +++ b/tests/test_endpoints_smoke.py @@ -0,0 +1,79 @@ +"""Smoke-Tests für die neuen API-Endpoints. + +Diese Tests prüfen nur ob die Endpoints antworten und das richtige +Format zurückgeben — keine echten LLM-Calls oder DB-Writes. +""" +import pytest + +# Skip wenn die App nicht importierbar ist (missing dependencies lokal) +try: + from fastapi.testclient import TestClient + from app.main import app + client = TestClient(app) + _HAS_APP = True +except ImportError: + _HAS_APP = False + client = None + + +pytestmark = pytest.mark.skipif(not _HAS_APP, reason="app.main not importable") + + +class TestQueueStatus: + def test_returns_json(self): + resp = client.get("/api/queue/status") + assert resp.status_code == 200 + data = resp.json() + assert "pending" in data + assert "worker_running" in data + + def test_pending_starts_at_zero(self): + data = client.get("/api/queue/status").json() + assert data["pending"] == 0 + + +class TestAuthMe: + def test_unauthenticated_returns_false(self): + resp = client.get("/api/auth/me") + assert resp.status_code == 200 + data = resp.json() + assert data["authenticated"] is False + + +class TestAuthLoginUrl: + def test_returns_enabled_flag(self): + resp = client.get("/api/auth/login-url") + assert resp.status_code == 200 + data = resp.json() + assert "enabled" in data + + +class TestBundeslaender: + def test_returns_list(self): + resp = client.get("/api/bundeslaender") + assert resp.status_code == 200 + data = resp.json() + assert isinstance(data, list) + assert len(data) > 10 # mindestens 10 BLs + + +class TestProgramme: + def test_returns_list(self): + resp = client.get("/api/programme") + assert resp.status_code == 200 + data = resp.json() + assert isinstance(data, list) + assert len(data) > 50 # mindestens 50 Programme + + def test_status_returns_indexed_count(self): + resp = client.get("/api/programme/status") + assert resp.status_code == 200 + data = resp.json() + assert "indexed" in data + assert "total" in data + + +class TestHealth: + def test_health(self): + resp = client.get("/health") + assert resp.status_code == 200