21 lines
863 B
Python
21 lines
863 B
Python
"""锁定 ShippingTaskEvent.task_id 指向正式订单任务,而非旧通知表。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from types import SimpleNamespace
|
|
|
|
from app.models import ShippingTaskEvent
|
|
from app.services.shipping_notice.tool_common import task_event_task_id
|
|
|
|
|
|
def test_shipping_task_event_points_to_order_task():
|
|
"""审计事件必须接受 ShippingOrderTask.id,避免确认建单时外键失败。"""
|
|
fk = next(iter(ShippingTaskEvent.__table__.c.task_id.foreign_keys))
|
|
assert fk.target_fullname == 'shipping_order_tasks.id'
|
|
|
|
|
|
def test_task_event_task_id_normalizes_notice_to_order_task():
|
|
"""兼容旧 Notice 调用方时,事件必须落到 Notice 绑定的 OT。"""
|
|
assert task_event_task_id(SimpleNamespace(id=99, order_task_id=28)) == 28
|
|
assert task_event_task_id(SimpleNamespace(id=99, order_task_id=None)) is None
|