"""Smoke tests for the FastAPI layer (no database needed).""" from __future__ import annotations def test_root(client) -> None: resp = client.get("/") assert resp.status_code == 200 def test_health_reports_database_and_search(client) -> None: resp = client.get("/api/health") assert resp.status_code == 200 body = resp.json() assert body["status"] in {"ok", "degraded"} assert body["database_name"] == "electronics_catalog_test" assert body["search"] == {"ddg": False, "google_cse": False} def test_openapi_lists_only_electronics_routes(client) -> None: paths = client.get("/openapi.json").json()["paths"] for expected in ("/api/health", "/api/auth/login", "/api/elec/categories", "/api/elec/brands", "/api/elec/products", "/api/elec/products/{product_id}", "/api/elec/sites", "/api/elec/admin/runs"): assert expected in paths, f"missing route: {expected}" grocery = [p for p in paths if any(w in p for w in ("nutrition", "catalog/generate", "stores", "discounts", "trending", "uploads", "brand-discovery"))] assert grocery == [] def test_admin_run_requires_admin(client, user_headers) -> None: assert client.post("/api/elec/admin/runs", json={"category": "mobiles"}).status_code == 401 assert client.post("/api/elec/admin/runs", json={"category": "mobiles"}, headers=user_headers).status_code == 403 def test_admin_run_rejects_brand_outside_allow_list(client, admin_headers) -> None: resp = client.post("/api/elec/admin/runs", json={"category": "mobiles", "brands": ["nokia"]}, headers=admin_headers) assert resp.status_code == 400