test(shipping): 更新订单复核库存与通知流程测试
This commit is contained in:
1 parent
8ec028e6a3
commit
265a6e179a
168 files changed
+9420
-4613
No files matched your search
@@ -294,3 +294,36 @@ def test_shadow_resolution_is_idempotent_and_accuracy_uses_labels_only(app):
|
||||
report = get_shadow_quality_report()
|
||||
assert labeled['is_correct'] is True
|
||||
assert report['labeled_count'] == 1 and report['accuracy'] == 1.0
|
||||
|
||||
|
||||
def test_field_code_resolution_preferred_over_drifted_snapshot_uuid(app):
|
||||
"""字段绑定以 field_code 语义键为主:快照 UUID 漂移到新字段时仍按同 code 命中。"""
|
||||
from app.services.shipping_notice.identity_resolution.resolver import _resolved_context_field_id
|
||||
|
||||
with app.app_context():
|
||||
field, version = _published_field(code='bill_to_customer')
|
||||
extraction = ShippingOrderExtraction(
|
||||
schema_version_id=version.id, input_snapshot_hash='a' * 64, status='accepted',
|
||||
)
|
||||
db.session.add(extraction)
|
||||
db.session.flush()
|
||||
definition = {
|
||||
'context_field_id': 'obsolete-uuid-no-longer-present', # 快照 UUID 已漂移,不在当前解析结果中。
|
||||
'field_config': {'field_code': 'bill_to_customer', 'scope': 'header', 'value_type': 'string'},
|
||||
}
|
||||
header_values = {str(field.id): {'value': 'buyer@example.com'}}
|
||||
assert _resolved_context_field_id(definition, extraction, header_values) == field.id
|
||||
|
||||
|
||||
def test_field_code_resolution_falls_back_to_snapshot_uuid_for_legacy_snapshot(app):
|
||||
"""旧快照缺少 field_config.field_code 时,仍按快照 UUID 直配命中,保持向后兼容。"""
|
||||
from app.services.shipping_notice.identity_resolution.resolver import _resolved_context_field_id
|
||||
|
||||
with app.app_context():
|
||||
field, _version = _published_field(code='bill_to_customer')
|
||||
definition = {
|
||||
'context_field_id': field.id,
|
||||
'field_config': {}, # 旧快照无 field_code,只能回退到 UUID 直配。
|
||||
}
|
||||
header_values = {str(field.id): {'value': 'buyer@example.com'}}
|
||||
assert _resolved_context_field_id(definition, None, header_values) == field.id
|
||||
Reference in new issue
Block a user