feat(1c): expose unresolved template descriptor codes
This commit is contained in:
@@ -4173,7 +4173,15 @@ def public_template_summary(
|
||||
}
|
||||
)
|
||||
descriptor_type_codes = sorted(
|
||||
{code for code in (template_descriptor_type_code_from_part(part) for part in parts) if code is not None},
|
||||
{
|
||||
code
|
||||
for code in (
|
||||
str(part.get("descriptor_type_code")) if str(part.get("descriptor_type_code") or "").isdecimal()
|
||||
else template_descriptor_type_code_from_part(part)
|
||||
for part in parts
|
||||
)
|
||||
if code is not None
|
||||
},
|
||||
key=int,
|
||||
)
|
||||
features = {
|
||||
@@ -42503,6 +42511,9 @@ def metadata_object_templates(payload: dict[str, Any]) -> dict[str, Any]:
|
||||
for part in parts_result.get("parts") or []:
|
||||
classification = part.get("classification") or {}
|
||||
public_part = payload_public_properties(classification)
|
||||
descriptor_type_code = template_descriptor_type_code_from_part(part)
|
||||
if descriptor_type_code is not None:
|
||||
public_part["descriptor_type_code"] = descriptor_type_code
|
||||
public_part["undecoded_evidence"] = payload_public_undecoded_evidence(
|
||||
classification,
|
||||
include_text_preview=bool(include_text),
|
||||
|
||||
@@ -7055,6 +7055,24 @@ def test_common_template_inventory_uses_parts_classifier(monkeypatch: pytest.Mon
|
||||
|
||||
assert result["templates"][0]["platform_type"] == "Двоичные данные"
|
||||
assert result["templates"][0]["content_type_evidence"]["xml_roots"] == ["AppearanceTemplate"]
|
||||
|
||||
|
||||
def test_common_template_inventory_preserves_unmapped_descriptor_code(monkeypatch: pytest.MonkeyPatch) -> 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, "metadata_object_parts", lambda _payload: {"parts": [{
|
||||
"role": "metadata_payload",
|
||||
"classification": {"tree": {"type": "list", "items": [
|
||||
{"type": "atom", "value": "1"},
|
||||
{"type": "list", "items": [
|
||||
{"type": "atom", "value": "4"}, {"type": "list", "items": []}, {"type": "atom", "value": "7"},
|
||||
]},
|
||||
]}},
|
||||
}, {"role": "content", "classification": {"xml_root": "AppearanceTemplate"}, "features": {}}]})
|
||||
|
||||
result = adapter_server.metadata_object_templates({"base_id": "upo_test", "kind": "CommonTemplate", "name": "Оформление"})
|
||||
|
||||
assert result["templates"][0]["descriptor_type_evidence"]["codes"] == ["7"]
|
||||
assert result["templates"][0]["name"] == "Оформление"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user