feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估
- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
1 parent
cef3d5b26a
commit
3a9fbac2fc
226 files changed
+25010
-2098
No files matched your search
@@ -75,14 +75,56 @@ def test_auto_progress_stops_at_must_human_parse_review(app) -> None:
|
||||
assert result.get("checkpoint") == CP_PARSE_REVIEW
|
||||
|
||||
|
||||
def test_try_auto_chain_never_calls_upload_even_when_auto_upload_enabled(app, monkeypatch) -> None:
|
||||
"""场景:禁 RPA 上传 — 即便 AUTO_UPLOAD=true,匹配后串联也不得调用 upload_to_freight。"""
|
||||
def test_try_auto_chain_calls_upload_when_auto_upload_enabled(app, monkeypatch) -> None:
|
||||
"""场景:AUTO_UPLOAD=true 时匹配后串联须调用 upload_to_freight(mode=auto)。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
app.config["SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_GENERATE_EXCEL_ENABLED"] = True
|
||||
|
||||
task = ShippingTask(
|
||||
task_no="SN-STP-RPA-ON",
|
||||
process_status="matched",
|
||||
match_status="fulfillable",
|
||||
source_type="manual",
|
||||
line_results_json=[{"line_status": "ok"}],
|
||||
export_file_path="/tmp/already.xlsx",
|
||||
export_file_name="already.xlsx",
|
||||
)
|
||||
db.session.add(task)
|
||||
db.session.commit()
|
||||
|
||||
upload_calls: list[dict] = []
|
||||
|
||||
def _fake_upload(payload):
|
||||
upload_calls.append(dict(payload or {}))
|
||||
return {"status": "running", "message": "rpa-triggered"}
|
||||
|
||||
monkeypatch.setattr(
|
||||
"app.services.shipping_notice.fulfillment_workflow.upload_to_freight",
|
||||
_fake_upload,
|
||||
)
|
||||
|
||||
result = try_auto_chain_after_match(
|
||||
task,
|
||||
{"status": "ok", "message": "matched"},
|
||||
payload={"task_id": task.task_no},
|
||||
)
|
||||
# 关键断言:自动链接入货代上传 RPA。
|
||||
assert len(upload_calls) == 1
|
||||
assert upload_calls[0].get("mode") == "auto"
|
||||
assert result["status"] == "running"
|
||||
|
||||
|
||||
def test_try_auto_chain_skips_upload_when_auto_upload_disabled(app, monkeypatch) -> None:
|
||||
"""场景:AUTO_UPLOAD=false 时停在人工上传,不调用 upload_to_freight。"""
|
||||
with app.app_context():
|
||||
from app import db
|
||||
|
||||
app.config["SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_AUTO_GENERATE_EXCEL_ENABLED"] = True
|
||||
|
||||
task = ShippingTask(
|
||||
task_no="SN-STP-NO-RPA",
|
||||
process_status="matched",
|
||||
|
||||
Reference in new issue
Block a user