本次提交完整实现货代发货通知的自动化批量处理能力: 1. 新增发货单票后台任务类型与专用worker队列,实现任务持久化调度 2. 实现发货批次后台编排器,支持上传后自动逐票推进解析、匹配、导出全流程 3. 新增单票重试、批次待处理重试的API与前端操作界面 4. 补充全量多语言翻译,新增重试、任务列表、状态展示相关文案 5. 优化上传交互逻辑,改为后台自动处理任务,无需手动触发解析指令 6. 修复文件检核工具无数据预检逻辑,避免创建空检核批次 7. 调整发货工作流细节,优化Excel生成幂等性与任务状态同步 8. 更新环境配置与API文档,修正货代工具接口地址端口
73 lines
2.1 KiB
Python
73 lines
2.1 KiB
Python
import pytest
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _isolate_persisted_settings(monkeypatch, tmp_path):
|
|
"""Prevent tests from inheriting the developer's local ``backend/.env``.
|
|
|
|
``apply_env_settings`` is called eagerly in ``create_app`` and on every
|
|
request via the ``before_request`` hook. If the dev's real ``backend/.env``
|
|
contains ``WECOM_AUTO_CREATE_USER=true`` (or any other WECOM_* override),
|
|
those values would silently overwrite the explicit ``app.config.update(...)``
|
|
calls inside test fixtures. Routing reads to a tmp path makes every test
|
|
start from a clean slate.
|
|
"""
|
|
from app import env_persistence
|
|
|
|
monkeypatch.setattr(env_persistence, 'LEGACY_BACKEND_ENV_PATH', tmp_path / 'isolated.env')
|
|
|
|
|
|
@pytest.fixture(autouse=True)
|
|
def _shipping_notice_stable_auto_config(app, request):
|
|
"""发货通知单测默认关闭 auto 链,避免 dev .env 开启 AUTO_PROGRESS 导致用例漂移。"""
|
|
if request.node.get_closest_marker("auto_rpa"):
|
|
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
|
|
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = True
|
|
app.config["SHIPPING_NOTICE_BATCH_ORCHESTRATOR_ENABLED"] = False
|
|
return
|
|
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = False
|
|
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = False
|
|
app.config["SHIPPING_NOTICE_BATCH_ORCHESTRATOR_ENABLED"] = False
|
|
|
|
|
|
def pytest_configure(config):
|
|
config.addinivalue_line(
|
|
"markers",
|
|
"auto_rpa: 发货通知测试启用 auto_progress + RPA 自动链",
|
|
)
|
|
|
|
|
|
@pytest.fixture
|
|
def app():
|
|
from app import create_app, db
|
|
|
|
app = create_app('testing')
|
|
with app.app_context():
|
|
db.create_all()
|
|
yield app
|
|
db.session.remove()
|
|
db.drop_all()
|
|
|
|
|
|
@pytest.fixture
|
|
def client(app):
|
|
return app.test_client()
|
|
|
|
|
|
@pytest.fixture
|
|
def admin_headers():
|
|
return {
|
|
'X-Username': 'admin',
|
|
'X-Role': 'admin',
|
|
'Content-Type': 'application/json'
|
|
}
|
|
|
|
|
|
@pytest.fixture
|
|
def user_headers():
|
|
return {
|
|
'X-Username': 'user',
|
|
'X-Role': 'user',
|
|
'Content-Type': 'application/json'
|
|
}
|