Public Access
feat: admin orchestrate endpoints — run-week, per-step, status
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -474,3 +474,52 @@ def test_run_week_calls_all_steps(monkeypatch):
|
||||
from app.services.orchestrator.runner import run_week
|
||||
run_week(WEEK)
|
||||
assert called == ["scrape", "generate", "email", "deadline", "finalize"]
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Admin endpoint tests
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
@pytest.fixture()
|
||||
def admin_client(db):
|
||||
from fastapi.testclient import TestClient
|
||||
from app.main import app
|
||||
from app.database import get_db
|
||||
|
||||
app.dependency_overrides[get_db] = lambda: db
|
||||
client = TestClient(app)
|
||||
yield client
|
||||
app.dependency_overrides.clear()
|
||||
|
||||
|
||||
ADMIN_HEADERS = {"Authorization": "Bearer test-admin-token"}
|
||||
|
||||
|
||||
def test_orchestrate_status_returns_list(admin_client, family, monkeypatch):
|
||||
from app.config import settings
|
||||
monkeypatch.setattr(settings, "ADMIN_TOKEN", "test-admin-token")
|
||||
resp = admin_client.get("/api/admin/orchestrate/status", headers=ADMIN_HEADERS)
|
||||
assert resp.status_code == 200
|
||||
assert "runs" in resp.json()
|
||||
|
||||
|
||||
def test_orchestrate_step_invalid_returns_400(admin_client, monkeypatch):
|
||||
from app.config import settings
|
||||
monkeypatch.setattr(settings, "ADMIN_TOKEN", "test-admin-token")
|
||||
resp = admin_client.post(
|
||||
"/api/admin/orchestrate/bogus", headers=ADMIN_HEADERS
|
||||
)
|
||||
assert resp.status_code == 400
|
||||
|
||||
|
||||
def test_orchestrate_run_week_returns_202(admin_client, monkeypatch):
|
||||
from app.config import settings
|
||||
monkeypatch.setattr(settings, "ADMIN_TOKEN", "test-admin-token")
|
||||
monkeypatch.setattr(
|
||||
"app.api.admin.run_week",
|
||||
lambda week=None: None,
|
||||
)
|
||||
resp = admin_client.post(
|
||||
"/api/admin/orchestrate/run-week", headers=ADMIN_HEADERS
|
||||
)
|
||||
assert resp.status_code == 202
|
||||
|
||||
Reference in New Issue
Block a user