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
@@ -4,7 +4,8 @@ tests/conftest.py
|
||||
用途:Flask testing app、库存配置种子与测试隔离夹具。
|
||||
依赖:pytest、app.create_app、shipping inventory 模型。
|
||||
逻辑:各测试用例共享;Windows 下将 basetemp 固定到 backend/.pytest_tmp,
|
||||
配合 pytest.ini 的 retention=0,避免 %TEMP%/pytest-current 清理 PermissionError。
|
||||
配合 pytest.ini 的 retention=0,避免 %TEMP%/pytest-current 清理 PermissionError;
|
||||
pure_unit 标记跳过 Flask/DB 创建,供契约类纯单测加速。
|
||||
"""
|
||||
|
||||
import shutil
|
||||
@@ -13,6 +14,18 @@ from pathlib import Path
|
||||
import pytest
|
||||
|
||||
|
||||
def pytest_configure(config):
|
||||
"""
|
||||
注册自定义标记,避免 PytestUnknownMarkWarning。
|
||||
|
||||
pure_unit:契约类纯单测,跳过 Flask/DB 创建(见 _shipping_notice_stable_auto_config)。
|
||||
"""
|
||||
config.addinivalue_line(
|
||||
'markers',
|
||||
'pure_unit: skip Flask app/DB creation unless the test requests the app fixture',
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _capture_legacy_order_rows_for_tests(monkeypatch):
|
||||
"""将旧测试夹具的 lines_json 参数暂存为动态订单输入,生产模型不保留该属性。"""
|
||||
@@ -94,8 +107,15 @@ def _isolate_persisted_settings(monkeypatch, tmp_path):
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def _shipping_notice_stable_auto_config(app, request, monkeypatch):
|
||||
"""发货通知单测默认关闭 auto 链,避免 dev .env 开启 AUTO_PROGRESS 导致用例漂移。"""
|
||||
def _shipping_notice_stable_auto_config(request, monkeypatch):
|
||||
"""
|
||||
发货通知单测默认关闭 auto 链,避免 dev .env 开启 AUTO_PROGRESS 导致用例漂移。
|
||||
|
||||
标记 pure_unit 且未显式请求 app 的用例跳过 Flask/DB 创建,显著降低契约类单测耗时。
|
||||
"""
|
||||
if request.node.get_closest_marker("pure_unit") and "app" not in request.fixturenames:
|
||||
return
|
||||
app = request.getfixturevalue("app")
|
||||
tmp_path = request.getfixturevalue("tmp_path")
|
||||
app.config["SHIPPING_NOTICE_RPA_SHARED_UPLOAD_QUEUE_DIR"] = str(tmp_path / "shipping_notice" / "freight_rpa" / "upload_queue")
|
||||
app.config["SHIPPING_NOTICE_RPA_SHARED_UPLOAD_TRIGGER_DIR"] = str(
|
||||
@@ -109,10 +129,14 @@ def _shipping_notice_stable_auto_config(app, request, monkeypatch):
|
||||
"app.services.shipping_notice.rpa_worker_heartbeat.assert_inventory_rpa_worker_ready",
|
||||
lambda: None,
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
"app.services.shipping_notice.rpa_worker_heartbeat.assert_freight_upload_rpa_ready",
|
||||
lambda: None,
|
||||
)
|
||||
return
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = False
|
||||
# STP 首期禁止货代 RPA 自动上传;单测默认与产品一致关闭。
|
||||
# 货代自动上传默认 fail-closed;单测与产品默认一致关闭。
|
||||
app.config["SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_BATCH_ORCHESTRATOR_ENABLED"] = False
|
||||
app.config["ENV_NAME"] = "dev"
|
||||
|
||||
Reference in new issue
Block a user