Files
shanxia2.0/backend/tests/test_pl_toxic_pending_confirm.py
T
wuzilongandCursor d22b06dbe7 feat(pl): 易制毒先安排待确认与购买证管理
含易制毒计划安排后进入已安排待确认,确认通过后再占合同并生成链接/地磅;新增购买证/运输证主数据、产品行关联、余量校验与 OCR 配置,并停止跟踪 api_key/app.pid。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-10-09 18:41:10 +08:00

61 lines
1.6 KiB
Python

"""P1: 易制毒待确认状态机与合同占用。"""
from app.services.pl_contract_plan_qty import _bucket_for_plan
def test_bucket_excludes_arranged_pending_confirm():
assert (
_bucket_for_plan(
archive_status="unarchived",
follow_status="arranged_pending_confirm",
transport_status="arranged",
)
is None
)
def test_bucket_arranged_still_occupies():
assert (
_bucket_for_plan(
archive_status="unarchived",
follow_status="arranged",
transport_status="arranged",
)
== "arranged_unarchived"
)
def test_collect_toxic_product_ids_ignores_explosive_only(monkeypatch):
"""仅易制爆不算毒,不进待确认。"""
from app.services import pl_plan_service as svc
class P:
def __init__(self, pid):
self.product_id = pid
def fake_map(db, tenant_no, ids):
return {
"toxic1": (1, 0),
"expl1": (0, 1),
"both1": (1, 1),
}
monkeypatch.setattr(svc, "fetch_hazard_flags_map", fake_map)
ids = svc.collect_toxic_product_ids(
None, "shanxia2.0", [P("toxic1"), P("expl1"), P("both1")]
)
assert ids == frozenset({"toxic1", "both1"})
def test_plan_has_toxic_products_false_for_explosive_only(monkeypatch):
from app.services import pl_plan_service as svc
class P:
product_id = "expl1"
monkeypatch.setattr(
svc,
"fetch_hazard_flags_map",
lambda *a, **k: {"expl1": (0, 1)},
)
assert svc.plan_has_toxic_products(None, "shanxia2.0", [P()]) is False