feat(shipping-notice): 添加订单文档 Profile 的样本和审计管理功能,支持样本绑定、审计记录和模板预览,增强文档模板的管理和验证能力
This commit is contained in:
1 parent
d62f5107b2
commit
93777fd6df
63 files changed
+9707
-1491
No files matched your search
@@ -24,6 +24,7 @@ from app.models import (
|
||||
ShippingOrderFieldValue,
|
||||
ShippingOrderSchemaAuditEvent,
|
||||
ShippingOrderSchemaVersion,
|
||||
ShippingOrderDocumentProfile,
|
||||
User,
|
||||
)
|
||||
from app.services.shipping_notice.order_schema import service
|
||||
@@ -468,6 +469,27 @@ def test_order_field_retire_is_blocked_by_active_cross_domain_config(app):
|
||||
assert getattr(exc_info.value, 'code', None) == 'SHIPPING.ORDER_FIELD_RETIRE_BLOCKED'
|
||||
|
||||
|
||||
def test_order_field_retire_is_blocked_by_v2_coordinate_profile(app):
|
||||
"""关键断言:v2 表头或明细字段区域引用的 field_id 也必须阻止字段退役。"""
|
||||
with app.app_context():
|
||||
service.initialize_schema({'display_name': '发货订单字段'}, actor_id=None)
|
||||
field = service.save_field({'field_code': 'coordinate_part', 'scope': 'line', 'value_type': 'string'}, actor_id=None)
|
||||
schema = service.get_state()['schema']
|
||||
version = service.create_draft({}, actor_id=None)
|
||||
db.session.add(ShippingOrderDocumentProfile(
|
||||
profile_code='V2_REFERENCE', display_name='V2 reference', version=1, status='draft',
|
||||
schema_version_id=version['id'], structure_fingerprint='a' * 64,
|
||||
definition_json={'contract_version': 'order_coordinate_profile.v2', 'table_regions': [{
|
||||
'header_layouts': [], 'line_layouts': [{'field_regions': [{'field_id': field['id']}]}],
|
||||
}]}, lock_version=1,
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
with pytest.raises(Exception) as exc_info:
|
||||
service.retire_field(field['id'])
|
||||
assert getattr(exc_info.value, 'code', None) == 'SHIPPING.ORDER_FIELD_RETIRE_BLOCKED'
|
||||
|
||||
|
||||
def test_schema_publish_cannot_omit_field_referenced_by_downstream_config(app):
|
||||
"""新 Schema 版本移除下游仍在使用的字段时,发布必须在运行前阻断。"""
|
||||
with app.app_context():
|
||||
|
||||
Reference in new issue
Block a user