Tests: 8 Endpoint-Smoke-Tests (queue, auth, programme, health)
This commit is contained in:
parent
3b6ecacc1e
commit
7ed2cca15f
79
tests/test_endpoints_smoke.py
Normal file
79
tests/test_endpoints_smoke.py
Normal file
@ -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
|
||||||
Loading…
Reference in New Issue
Block a user