Decode SCD data sources from live XML

This commit is contained in:
2026-08-14 12:04:12 +03:00
parent adc5d88e5f
commit 41a3f47c69
4 changed files with 29 additions and 3 deletions
+4 -1
View File
@@ -211,6 +211,7 @@ def test_dbnames_version_parser_accepts_utf8_bom_scalar_version() -> None:
def test_scd_payload_decoder_reads_xml_after_platform_prefix() -> None:
xml = """<?xml version="1.0" encoding="UTF-8"?>
<SchemaFile><dataCompositionSchema>
<dataSource><name>ИсточникДанных1</name><dataSourceType>Local</dataSourceType></dataSource>
<dataSet xsi:type="DataSetQuery" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><name>ОсновнойНабор</name><query>ВЫБРАТЬ &amp;Период КАК Период // &amp;Скрытый КАК Скрытый</query></dataSet>
<parameter><name>Период</name><valueType>xs:dateTime</valueType></parameter>
<field><dataPath>Период</dataPath></field>
@@ -226,6 +227,7 @@ def test_scd_payload_decoder_reads_xml_after_platform_prefix() -> None:
assert result["status"] == "ok"
assert result["container"]["compression"] == "raw_deflate"
assert result["sections"]["data_sources"] == [{"name": "ИсточникДанных1", "source": {"kind": "scd_xml", "path": "/dataCompositionSchema[1]/dataSource"}, "data_source_type": "Local"}]
assert result["sections"]["parameters"] == [{"name": "Период", "source": {"kind": "scd_xml", "path": "/dataCompositionSchema[1]/parameter"}, "value_type": "xs:dateTime"}]
assert result["sections"]["datasets"][0]["query"] == "ВЫБРАТЬ &Период КАК Период // &Скрытый КАК Скрытый"
assert result["sections"]["calculated_fields"][0]["expression"] == "Сумма * 1.2"
@@ -236,13 +238,14 @@ def test_scd_payload_decoder_reads_xml_after_platform_prefix() -> None:
"top_level": [
{"tag": "calculatedField", "count": 1, "paths": ["/dataCompositionSchema[1]/calculatedField"]},
{"tag": "dataSet", "count": 1, "paths": ["/dataCompositionSchema[1]/dataSet"]},
{"tag": "dataSource", "count": 1, "paths": ["/dataCompositionSchema[1]/dataSource"]},
{"tag": "field", "count": 2, "paths": ["/dataCompositionSchema[1]/field", "/dataCompositionSchema[1]/field[2]"]},
{"tag": "parameter", "count": 1, "paths": ["/dataCompositionSchema[1]/parameter"]},
{"tag": "resource", "count": 1, "paths": ["/dataCompositionSchema[1]/resource"]},
{"tag": "settingsVariant", "count": 1, "paths": ["/dataCompositionSchema[1]/settingsVariant"]},
{"tag": "totalField", "count": 1, "paths": ["/dataCompositionSchema[1]/totalField"]},
],
"all_tag_counts": {"calculatedField": 1, "dataCompositionSchema": 1, "dataPath": 2, "dataSet": 1, "expression": 2, "field": 2, "name": 5, "parameter": 1, "query": 1, "resource": 1, "settingsVariant": 1, "totalField": 1, "valueType": 1},
"all_tag_counts": {"calculatedField": 1, "dataCompositionSchema": 1, "dataPath": 2, "dataSet": 1, "dataSource": 1, "dataSourceType": 1, "expression": 2, "field": 2, "name": 6, "parameter": 1, "query": 1, "resource": 1, "settingsVariant": 1, "totalField": 1, "valueType": 1},
}
assert result["analysis"]["referenced_not_declared_in_schema"] == []
assert result["analysis"]["total_field_references"] == {"fields": ["Сумма"], "missing_from_declared_fields": [], "status": "checked"}