fix(1c): retain descriptor role in template inventory
This commit is contained in:
@@ -4105,9 +4105,10 @@ def template_descriptor_type_code_from_part(part: dict[str, Any]) -> str | None:
|
|||||||
The code is useful evidence, but its numeric-to-TemplateType mapping is
|
The code is useful evidence, but its numeric-to-TemplateType mapping is
|
||||||
intentionally not guessed from the payload carrier or a template name.
|
intentionally not guessed from the payload carrier or a template name.
|
||||||
"""
|
"""
|
||||||
if str(part.get("role") or "") != "metadata_payload":
|
|
||||||
return None
|
|
||||||
classification = part.get("classification") if isinstance(part.get("classification"), dict) else {}
|
classification = part.get("classification") if isinstance(part.get("classification"), dict) else {}
|
||||||
|
role = str(part.get("role") or classification.get("role") or "")
|
||||||
|
if role != "metadata_payload":
|
||||||
|
return None
|
||||||
tree = classification.get("tree")
|
tree = classification.get("tree")
|
||||||
if not isinstance(tree, dict):
|
if not isinstance(tree, dict):
|
||||||
return None
|
return None
|
||||||
@@ -42511,6 +42512,8 @@ def metadata_object_templates(payload: dict[str, Any]) -> dict[str, Any]:
|
|||||||
for part in parts_result.get("parts") or []:
|
for part in parts_result.get("parts") or []:
|
||||||
classification = part.get("classification") or {}
|
classification = part.get("classification") or {}
|
||||||
public_part = payload_public_properties(classification)
|
public_part = payload_public_properties(classification)
|
||||||
|
if classification.get("role"):
|
||||||
|
public_part["role"] = classification.get("role")
|
||||||
descriptor_type_code = template_descriptor_type_code_from_part(part)
|
descriptor_type_code = template_descriptor_type_code_from_part(part)
|
||||||
if descriptor_type_code is not None:
|
if descriptor_type_code is not None:
|
||||||
public_part["descriptor_type_code"] = descriptor_type_code
|
public_part["descriptor_type_code"] = descriptor_type_code
|
||||||
|
|||||||
@@ -7061,14 +7061,13 @@ def test_common_template_inventory_preserves_unmapped_descriptor_code(monkeypatc
|
|||||||
monkeypatch.setattr(adapter_server, "resolve_object_guid", lambda *_args, **_kwargs: ("a" * 36, None, {"name": "Оформление", "ref": "CommonTemplate.Оформление"}, None))
|
monkeypatch.setattr(adapter_server, "resolve_object_guid", lambda *_args, **_kwargs: ("a" * 36, None, {"name": "Оформление", "ref": "CommonTemplate.Оформление"}, None))
|
||||||
monkeypatch.setattr(adapter_server, "read_template_by_guid", lambda _payload: {"status": "ok", "source": {"kind": "live_sql"}, "templates": [{"guid": "a" * 36}]})
|
monkeypatch.setattr(adapter_server, "read_template_by_guid", lambda _payload: {"status": "ok", "source": {"kind": "live_sql"}, "templates": [{"guid": "a" * 36}]})
|
||||||
monkeypatch.setattr(adapter_server, "metadata_object_parts", lambda _payload: {"parts": [{
|
monkeypatch.setattr(adapter_server, "metadata_object_parts", lambda _payload: {"parts": [{
|
||||||
"role": "metadata_payload",
|
"classification": {"role": "metadata_payload", "tree": {"type": "list", "items": [
|
||||||
"classification": {"tree": {"type": "list", "items": [
|
|
||||||
{"type": "atom", "value": "1"},
|
{"type": "atom", "value": "1"},
|
||||||
{"type": "list", "items": [
|
{"type": "list", "items": [
|
||||||
{"type": "atom", "value": "4"}, {"type": "list", "items": []}, {"type": "atom", "value": "7"},
|
{"type": "atom", "value": "4"}, {"type": "list", "items": []}, {"type": "atom", "value": "7"},
|
||||||
]},
|
]},
|
||||||
]}},
|
]}},
|
||||||
}, {"role": "content", "classification": {"xml_root": "AppearanceTemplate"}, "features": {}}]})
|
}, {"classification": {"role": "binary_or_unknown_payload", "xml_root": "AppearanceTemplate"}, "features": {}}]})
|
||||||
|
|
||||||
result = adapter_server.metadata_object_templates({"base_id": "upo_test", "kind": "CommonTemplate", "name": "Оформление"})
|
result = adapter_server.metadata_object_templates({"base_id": "upo_test", "kind": "CommonTemplate", "name": "Оформление"})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user