diff --git a/Dockerfile b/Dockerfile index 1c5ef3d..e038685 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,5 +10,11 @@ ENV FIRSTSYNC_STATE_DIR=/data ENV FIRSTSYNC_PORTAL_PORT=8000 RUN mkdir -p /data +# The package is installed into site-packages, but the test orgs and the demo proposals +# live at the repo root (copied to /app). Point the lookups at their absolute paths so +# they resolve regardless of where the package itself sits. +ENV FIRSTSYNC_ORGS_DIR=/app/orgs +ENV FIRSTSYNC_DEMO_RESULTS_DIR=/app/results + EXPOSE 8000 CMD ["firstsync", "portal"] diff --git a/tests/test_portal.py b/tests/test_portal.py index 8235a5e..d6692b2 100644 --- a/tests/test_portal.py +++ b/tests/test_portal.py @@ -69,3 +69,18 @@ def test_unknown_org_is_rejected(client): def test_healthz(client): assert client.get("/healthz").json() == {"status": "ok"} + + +def test_data_dirs_resolve_from_env(monkeypatch): + """The deploy scenario: the package is installed away from the orgs/ and results/ + folders, so they are located via FIRSTSYNC_ORGS_DIR and FIRSTSYNC_DEMO_RESULTS_DIR + (as the Dockerfile sets them). The index must still list every org.""" + from pathlib import Path + + root = Path(__file__).resolve().parents[1] + monkeypatch.setenv("FIRSTSYNC_ORGS_DIR", str(root / "orgs")) + monkeypatch.setenv("FIRSTSYNC_DEMO_RESULTS_DIR", str(root / "results")) + body = TestClient(app).get("/").text + for org in ("org_a", "org_b", "org_c", "org_d", "org_e", "org_f"): + assert org in body + assert "Claude's mapping ready" in body # demo proposals located too