feat: extend operational investigation workflows
Generic Container CI/CD / test-build-publish (push) Successful in 3m53s
Server CI/CD v2 / build-test-publish-and-deploy (push) Successful in 3m52s

This commit is contained in:
2026-10-30 17:30:19 +08:00
parent 63af998045
commit 05183aff93
82 changed files with 4644 additions and 330 deletions
+39
View File
@@ -0,0 +1,39 @@
import asyncio
from uuid import uuid4
from fastapi import FastAPI
from fastapi.testclient import TestClient
from app.api.v1.endpoints import operational_tasks as endpoints
from tests.unit.test_task_questions import setup, finish
def test_question_http_contract_waits_and_resumes_original_task(monkeypatch):
service, repo, task_id, command = setup()
app = FastAPI()
app.include_router(endpoints.router)
monkeypatch.setattr(endpoints, "_service", lambda *_args: service)
# Exercise HTTP parsing and response contracts; service tests cover authorization.
for route in app.routes:
if getattr(route, "name", "") in {"create_operational_task_question", "answer_operational_task_question"}:
for dependency in route.dependant.dependencies:
app.dependency_overrides[dependency.call] = lambda: None
with TestClient(app) as client:
path = f"/operational-tasks/{task_id}/questions"
invalid = client.post(path, json={**command.model_dump(mode="json"), "project_id": str(uuid4())})
assert invalid.status_code == 422
created = client.post(path, json=command.model_dump(mode="json"))
assert created.status_code == 200, created.text
question_id = created.json()["question_request_id"]
asyncio.run(finish(service, repo, task_id))
answered = client.post(f"{path}/{question_id}/answer", json={
"request_id": str(uuid4()), "expected_version": 1,
"answers": [{"question_id": "flow", "selected_option_ids": ["unknown"], "custom_text": ""}],
})
assert answered.status_code == 200, answered.text
result = answered.json()
assert result["task_id"] == str(task_id) and result["execution_generation"] == 2
assert result["active_run"]["status"] == "queued"
assert result["questions"][0]["status"] == "answered"
assert result["questions"][0]["answered_by"] == service._actor()
assert result["evidence"] == []