feat: extend operational investigation workflows
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
from uuid import uuid4
|
||||
|
||||
import pytest
|
||||
from pydantic import ValidationError
|
||||
|
||||
from samples.peripheral.auth import Identity
|
||||
from samples.peripheral.config import SampleSettings
|
||||
@@ -29,6 +30,7 @@ def test_create_and_update_record_flat_order_activity(monkeypatch):
|
||||
feedback_requirements=["回传开度照片"],
|
||||
))
|
||||
assert created["feedback_requirements"] == ["回传开度照片"]
|
||||
assert created["origin"] == "system_data"
|
||||
assert created["activity"][0]["kind"] == "created"
|
||||
assert "subtasks" not in created
|
||||
|
||||
@@ -37,6 +39,7 @@ def test_create_and_update_record_flat_order_activity(monkeypatch):
|
||||
progress_note="已复核开度,等待回执确认",
|
||||
))
|
||||
assert updated["status"] == "awaiting_reply"
|
||||
assert updated["origin"] == "system_data"
|
||||
assert [entry["sequence"] for entry in updated["activity"]] == [1, 2]
|
||||
assert updated["activity"][1]["kind"] == "feedback"
|
||||
assert updated["activity"][1]["detail"] == "已复核开度,等待回执确认"
|
||||
@@ -68,3 +71,21 @@ def test_legacy_order_reads_flat_without_claiming_unrecorded_progress():
|
||||
assert "subtasks" not in projected
|
||||
assert projected["feedback_requirements"] == []
|
||||
assert projected["activity"] == []
|
||||
|
||||
|
||||
def test_work_order_contract_rejects_synthetic_origin():
|
||||
with pytest.raises(ValidationError):
|
||||
CreateWorkOrder(
|
||||
request_id=uuid4(), title="来源校验", summary="只接受系统数据", origin="synthetic",
|
||||
)
|
||||
|
||||
|
||||
def test_legacy_work_order_origin_is_normalized_for_reads():
|
||||
legacy = {
|
||||
"work_order_id": str(uuid4()), "project_id": str(uuid4()), "revision": 1,
|
||||
"title": "历史工单", "summary": "迁移前记录", "status": "open", "priority": "normal",
|
||||
"assignee": None, "scheduled_at": None, "origin": "synthetic",
|
||||
"created_at": "2026-09-18T00:00:00Z", "updated_at": "2026-09-18T00:00:00Z",
|
||||
"created_by": str(uuid4()), "updated_by": str(uuid4()),
|
||||
}
|
||||
assert WorkOrder.model_validate(legacy).origin == "system_data"
|
||||
|
||||
Reference in New Issue
Block a user