feat: move delivery notification into dao transitions
Some checks failed
CI / pytest (Python 3.10) (push) Has been cancelled
CI / pytest (Python 3.11) (push) Has been cancelled
CI / pytest (Python 3.12) (push) Has been cancelled

This commit is contained in:
Hermes Agent
2026-06-14 17:35:37 +08:00
parent 08148fe282
commit 4b0390a255
4 changed files with 67 additions and 31 deletions

View File

@@ -77,3 +77,36 @@ def test_report_ready_transition_creates_notification_event(
notification_service.close()
assert len(events) == 1
assert events[0].event_type == "report_ready"
def test_dao_delivered_transition_also_creates_notification_event(settings, tmp_path):
order = _seed_order(settings.orders_db_path, order_id="GKO-20260614-NOTIFY-DAO")
_mark_paid(settings, order)
IntakeStore.for_db(settings.orders_db_path).save(
order_id=order.id, payload={"candidate_score": 578}, submit=True
)
report_path = tmp_path / "dao-report.html"
pdf_path = tmp_path / "dao-report.pdf"
report_path.write_text("<h1>dao</h1>", encoding="utf-8")
pdf_path.write_bytes(b"%PDF-1.4\ndao\n")
with OrdersDAO.connect(settings.orders_db_path) as dao:
dao.update(
order.id,
{"audit_report": str(report_path), "pdf_path": str(pdf_path)},
actor="test",
reason="attach_report",
)
dao.transition_status(order.id, "serving", actor="test", reason="processing")
dao.transition_status(
order.id, "delivered", actor="test", reason="report_ready"
)
notification_service = DeliveryNotificationService.for_db(settings.orders_db_path)
try:
events = notification_service.list_events(order.id)
finally:
notification_service.close()
assert len(events) == 1
assert events[0].event_type == "report_ready"