执行中的运输计划不再随意改单;库存流水记到装卸产品明细;手工派车日历区分酸碱并记录数量。同时收紧合同附件与子表的差量保存,并清理已废弃的 bak 备份目录。 Co-authored-by: Cursor <cursoragent@cursor.com>
38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from types import SimpleNamespace
|
|
from unittest.mock import MagicMock, patch
|
|
|
|
import pytest
|
|
|
|
from app.api.pl.plan import cancel_plan, _filters_from_params
|
|
from app.services.pl_plan_archive_export import ARCHIVE_STATUS_LABELS
|
|
|
|
|
|
@pytest.mark.parametrize("archive_status", ["unarchived", "draft"])
|
|
def test_cancel_plan_persists_cancelled_archive_status(archive_status):
|
|
plan = SimpleNamespace(
|
|
id="p1", follow_status="arranged", archive_status=archive_status,
|
|
transport_status="arranged", transport_id=None,
|
|
)
|
|
db = MagicMock()
|
|
user = MagicMock(id="u1")
|
|
with patch("app.api.pl.plan.get_tenant_no", return_value="t1"), patch(
|
|
"app.api.pl.plan._get_plan", return_value=plan
|
|
), patch(
|
|
"app.api.pl.plan.plan_execution_lock_reason", return_value=None
|
|
), patch("app.api.pl.plan.void_io_orders_for_plan"):
|
|
result = cancel_plan("p1", body=None, db=db, user=user)
|
|
assert result.follow_status == "cancelled"
|
|
assert result.archive_status == "cancelled"
|
|
db.commit.assert_called_once()
|
|
db.refresh.assert_called_once_with(plan)
|
|
|
|
|
|
def test_cancelled_archive_status_export_label():
|
|
assert ARCHIVE_STATUS_LABELS.get("cancelled") == "已取消"
|
|
|
|
|
|
def test_archive_list_scope_passes_through_list_and_export_params():
|
|
with patch("app.api.pl.plan.build_plan_column_filters", return_value=[]) as build:
|
|
_filters_from_params({"archiveList": "1"}, db=None, tenant_no="t1")
|
|
assert build.call_args.kwargs["archive_list"] is True
|