feat(in-transit-transfer): inbound/outbound 幂等重命名与解析用途分层
- receipt→inbound 三件套改名(回调桥/文件门禁/触发服务),回调链幂等去重,迁移 tt14 同步台账键与测试基建 - 库存解析用途分层 onhand/inbound/outbound(迁移 tt15):解析档案、文件存储与下载名按用途隔离,管理端表单同步 - 「成熟」概念退役(迁移 tt16):数据无成熟属性,日期边界由调用方入参严格判定 - backlog 新增重解析服务,在途重识别投影 processing,EML 父项不再停留处理中 - 收料 RPA 回调/归档/排程链路同步改名挂点,运维脚本复位假完成状态 - 文档随批:ADR 0003 模块边界决策、10-15/10-16 计划与设计、调拨文档族与 demand/tec/funclist - 同步 chat/errors 文案四语言、调拨前端卡片与 e2e、测试全家
This commit is contained in:
1 parent
43dceaf027
commit
8102a1fe44
151 files changed
+8057
-2382
No files matched your search
@@ -8,6 +8,8 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from app.models import ShippingAuditEvent, ShippingInventorySource, User
|
||||
from tests.conftest import parse_api_data, parse_api_error
|
||||
|
||||
@@ -156,8 +158,8 @@ def test_receipt_config_rejects_date_selector_and_invalid_connector_rules(app, c
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
|
||||
def _create_movement_profile(profile_code: str, *, status: str, purpose: str):
|
||||
"""创建异动/库存解析 Profile 种子;定义仅用于绑定校验,不参与解析。"""
|
||||
def _create_parsing_profile(profile_code: str, *, status: str, purpose: str):
|
||||
"""创建入站/在手解析 Profile 种子;定义仅用于绑定校验,不参与解析。"""
|
||||
from app import db
|
||||
from app.models import ShippingInventoryParsingProfile
|
||||
|
||||
@@ -174,14 +176,14 @@ def _create_movement_profile(profile_code: str, *, status: str, purpose: str):
|
||||
return profile
|
||||
|
||||
|
||||
def test_receipt_config_binds_published_movement_profile(app, client):
|
||||
"""绑定已发布 movement 规则 → 保存成功,payload 携带 parsing_profile_id 与摘要,审计留痕。"""
|
||||
def test_receipt_config_binds_published_inbound_profile(app, client):
|
||||
"""绑定已发布 inbound 规则 → 保存成功,payload 携带 parsing_profile_id 与摘要,审计留痕。"""
|
||||
app.config['AUTH_JWT_REQUIRED'] = False
|
||||
with app.app_context():
|
||||
_create_users()
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
source_id = source.id
|
||||
profile = _create_movement_profile('CRANE_MOVE_STD', status='published', purpose='movement')
|
||||
profile = _create_parsing_profile('CRANE_MOVE_STD', status='published', purpose='inbound')
|
||||
profile_id = profile.id
|
||||
|
||||
payload = {**_dbs_payload(), 'parsing_profile_id': profile_id}
|
||||
@@ -203,16 +205,16 @@ def test_receipt_config_binds_published_movement_profile(app, client):
|
||||
assert audit.metadata_json['parsing_profile_id'] == profile_id
|
||||
|
||||
|
||||
def test_receipt_config_rejects_draft_or_non_movement_profile(app, client):
|
||||
"""draft/库存用途/不存在 的规则一律拒绝,防止误绑导致预检无法解析收料文件。"""
|
||||
def test_receipt_config_rejects_draft_or_non_inbound_profile(app, client):
|
||||
"""draft/在手用途/不存在 的规则一律拒绝,防止误绑导致预检无法解析收料文件。"""
|
||||
app.config['AUTH_JWT_REQUIRED'] = False
|
||||
with app.app_context():
|
||||
_create_users()
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
source_id = source.id
|
||||
draft = _create_movement_profile('MOVE_DRAFT', status='draft', purpose='movement')
|
||||
inventory_profile = _create_movement_profile('INV_PUBLISHED', status='published', purpose='inventory')
|
||||
cases = [draft.id, inventory_profile.id, 999999]
|
||||
draft = _create_parsing_profile('MOVE_DRAFT', status='draft', purpose='inbound')
|
||||
onhand_profile = _create_parsing_profile('INV_PUBLISHED', status='published', purpose='onhand')
|
||||
cases = [draft.id, onhand_profile.id, 999999]
|
||||
|
||||
for profile_id in cases:
|
||||
response = client.put(
|
||||
@@ -221,8 +223,8 @@ def test_receipt_config_rejects_draft_or_non_movement_profile(app, client):
|
||||
headers=_headers('receipt-admin', 'admin'),
|
||||
)
|
||||
assert response.status_code == 400, f'profile_id={profile_id}'
|
||||
# 关键断言:非"已发布 movement"绑定必须走统一错误码,fail-closed。
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_MOVEMENT_PROFILE_INVALID'
|
||||
# 关键断言:非"已发布 inbound"绑定必须走统一错误码,fail-closed。
|
||||
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.INBOUND_PROFILE_INVALID'
|
||||
|
||||
|
||||
def test_receipt_config_empty_profile_id_unbinds(app, client):
|
||||
@@ -232,7 +234,7 @@ def test_receipt_config_empty_profile_id_unbinds(app, client):
|
||||
_create_users()
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
source_id = source.id
|
||||
profile = _create_movement_profile('MOVE_UNBIND', status='published', purpose='movement')
|
||||
profile = _create_parsing_profile('MOVE_UNBIND', status='published', purpose='inbound')
|
||||
profile_id = profile.id
|
||||
|
||||
bound = client.put(
|
||||
@@ -292,3 +294,36 @@ def test_crane_receipt_config_rejects_query_parameters(app, client):
|
||||
)
|
||||
assert rejected.status_code == 400
|
||||
assert parse_api_error(rejected.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
|
||||
|
||||
|
||||
def test_retire_rejects_profile_bound_by_receipt_report_config(app):
|
||||
"""绑定收料报表配置的 published 解析 Profile 退役必须被拒(退役守卫补查)。
|
||||
|
||||
背景:retire 此前只核查库存源(ShippingInventorySource)绑定,遗漏了
|
||||
收料报表配置(ShippingReceiptReportConfig.parsing_profile_id)——入站文件
|
||||
解析链会因规则退役静默失去规则。守卫补查后两者任一绑定都返回
|
||||
SHIPPING.INVENTORY_PARSING_PROFILE_RETIRE_BLOCKED。
|
||||
"""
|
||||
from app import db
|
||||
from app.models import ShippingReceiptReportConfig
|
||||
from app.services.shipping_notice import inventory_parsing_profile
|
||||
|
||||
app.config['AUTH_JWT_REQUIRED'] = False
|
||||
with app.app_context():
|
||||
_create_users()
|
||||
source = ShippingInventorySource.query.filter_by(source_code='DSV360_AWSDU').one()
|
||||
profile = _create_parsing_profile('MOVE_RETIRE_GUARD', status='published', purpose='inbound')
|
||||
db.session.add(ShippingReceiptReportConfig(
|
||||
inventory_source_id=source.id, parsing_profile_id=profile.id,
|
||||
report_path_json={}, query_parameters_json=[],
|
||||
))
|
||||
db.session.commit()
|
||||
profile_id = profile.id
|
||||
|
||||
# 关键断言:仅绑定收料配置(无库存源绑定)也必须拒绝退役,沿用既有错误码。
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
inventory_parsing_profile.retire(profile_id)
|
||||
assert getattr(exc_info.value, 'code', '') == 'SHIPPING.INVENTORY_PARSING_PROFILE_RETIRE_BLOCKED'
|
||||
|
||||
# 关键断言:被拒后 Profile 状态保持 published,不得被半退役。
|
||||
assert ShippingReceiptReportConfig.query.filter_by(parsing_profile_id=profile_id).count() == 1
|
||||
Reference in new issue
Block a user