|
| 1 | +#docker-compose -f local.yml run --rm django pytest config_generation/tests/test_db_to_xml.py |
1 | 2 | from xml.etree.ElementTree import ElementTree, ParseError, fromstring
|
2 | 3 |
|
3 | 4 | import pytest
|
@@ -84,14 +85,20 @@ def test_add_new_element():
|
84 | 85 | updated_xml = editor.update_config_xml()
|
85 | 86 | assert "Value" in updated_xml and "<newchild>Value</newchild>" in updated_xml
|
86 | 87 |
|
87 |
| - |
88 |
| -def test_add_complex_element_structure(): |
| 88 | +def test_add_third_level_hierarchy(): |
89 | 89 | xml_string = "<root></root>"
|
90 | 90 | editor = XmlEditor(xml_string)
|
91 |
| - editor.update_or_add_element_value("parent/child", "Nested") |
| 91 | + editor.update_or_add_element_value("parent/child/grandchild", "DeeplyNested") |
92 | 92 | updated_xml = editor.update_config_xml()
|
93 |
| - assert "Nested" in updated_xml and "<child>Nested</child>" in updated_xml |
94 |
| - |
| 93 | + root = fromstring(updated_xml) |
| 94 | + grandchild = root.find('.//grandchild') |
| 95 | + assert grandchild is not None, "Grandchild element not found" |
| 96 | + assert grandchild.text == "DeeplyNested", "Grandchild does not contain the correct text" |
| 97 | + |
| 98 | + # Check complete path |
| 99 | + parent = root.find('.//parent/child/grandchild') |
| 100 | + assert parent is not None, "Complete path to grandchild not found" |
| 101 | + assert parent.text == "DeeplyNested", "Complete path to grandchild does not contain correct text" |
95 | 102 |
|
96 | 103 | # Test transformations and generic mapping
|
97 | 104 | def test_convert_indexer_to_scraper_transformation():
|
|
0 commit comments