Spaces:
Sleeping
Sleeping
Sam Cole
Claude Opus 4.8 (1M context)
Self-improving dev/test/deploy loop: frozen tests, diff-based evolution engine, CI
887650c Download tests/conftest.py from colesr/insight-engine-docker: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/spaces/colesr/insight-engine-docker/resolve/main/tests/conftest.py
- Command line
-
hf download hf://spaces/colesr/insight-engine-docker/tests/conftest.py
-
curl -L -o conftest.py https://huggingface.co/spaces/colesr/insight-engine-docker/resolve/main/tests/conftest.py
1.63 kB
| """ | |
| Shared fixtures for the FROZEN fitness suite. | |
| The app is imported and driven black-box via FastAPI's TestClient so the tests | |
| survive internal refactors (a mutation may rename functions freely as long as the | |
| HTTP contracts hold). We deliberately build the client WITHOUT the `with` context | |
| manager: that skips the app's startup event (an 8s globe prewarm that would hit the | |
| network), keeping the suite offline, fast, and deterministic. | |
| """ | |
| import sys | |
| from pathlib import Path | |
| import pytest | |
| from fastapi.testclient import TestClient | |
| # Repo root on sys.path so `import main` works when pytest runs from anywhere. | |
| ROOT = Path(__file__).resolve().parent.parent | |
| sys.path.insert(0, str(ROOT)) | |
| from main import app # noqa: E402 | |
| def client(): | |
| # No context manager -> startup/shutdown events do not fire (no network prewarm). | |
| return TestClient(app) | |
| def _upload(client, indicators, records, name="fixture"): | |
| """Upload a dataset and return its id. Caller is responsible for shape.""" | |
| resp = client.post( | |
| "/api/dataset/upload", | |
| json={"name": name, "indicators": indicators, "records": records}, | |
| ) | |
| assert resp.status_code == 200, resp.text | |
| return resp.json()["dataset_id"] | |
| def uploaded(client): | |
| """Factory that uploads a dataset and cleans it up afterwards.""" | |
| created = [] | |
| def _make(indicators, records, name="fixture"): | |
| ds_id = _upload(client, indicators, records, name) | |
| created.append(ds_id) | |
| return ds_id | |
| yield _make | |
| for ds_id in created: | |
| client.delete(f"/api/dataset/{ds_id}") | |