tests/: conftest.py - minimale Env-Vars + sys.path-Setup test_auth.py - Magic-Token + JWT Round-Trip (4 Tests) test_audit.py - diff() + _to_json() Helper (8 Tests) test_models.py - Pydantic-Validierung (7 Tests) test_source_meta.py - Single Source of Truth Konsistenz (7 Tests) test_imports.py - alle Backend-Module importierbar (4 Tests) requirements-dev.txt: pytest, ftfy, pyflakes Tests sind reine Unit-Tests (kein DB-Zugriff, kein HTTP-Server), laufen in <0.5s, geben sofortiges Catch-Net fuer Syntax/Import-Bugs. Aufruf: PYTHONPATH=src ./venv/bin/python -m pytest tests/ -v CLAUDE.md erweitert um: - Sektion Tests (Framework, Pfad, Ausfuehrung) - Sektion Phasen-Historie (alle 12 Phasen der Aufraeum-Aktion 2026-05-09 mit kurzer Erklaerung)
34 Zeilen
1.4 KiB
Python
34 Zeilen
1.4 KiB
Python
"""Smoke-Test: alle Backend-Module importierbar (Catch-Net fuer Syntax-Errors)."""
|
|
import importlib
|
|
|
|
|
|
def test_main_app_imports():
|
|
import main # FastAPI app
|
|
assert hasattr(main, "app")
|
|
|
|
|
|
def test_all_routers_importable():
|
|
"""Bei Syntax-Fehlern in einem Router crasht das Ganze - hier fangen wir das ab."""
|
|
for mod in ("auth", "organizations", "licenses", "users",
|
|
"dashboard", "sources", "token_usage", "audit"):
|
|
m = importlib.import_module(f"routers.{mod}")
|
|
assert hasattr(m, "router"), f"routers/{mod} hat keinen router-Objekt"
|
|
|
|
|
|
def test_shared_modules_importable():
|
|
"""src/shared/ muss eigenstaendig importierbar sein (kein sys.path-Hack)."""
|
|
from shared.source_rules import discover_source, evaluate_feeds_with_claude
|
|
from shared.services.source_health import run_health_checks
|
|
from shared.services.source_suggester import generate_suggestions
|
|
from shared.agents.claude_client import call_claude
|
|
assert callable(discover_source)
|
|
assert callable(run_health_checks)
|
|
|
|
|
|
def test_helpers_importable():
|
|
from auth import generate_magic_token, create_token, decode_token
|
|
from audit import log_action, diff, get_client_ip, row_to_dict
|
|
from email_utils.sender import send_email
|
|
from email_utils.templates import portal_magic_link_email, invite_email
|
|
from source_meta import get_meta, category_label, type_label
|