Skip to content

Commit 6cfa5f7

Browse files
author
Your Name
committed
Address the comment made in the PR review
1 parent 71e1795 commit 6cfa5f7

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,9 @@ For each PR made, an entry should be added to this changelog. It should contain
4242
- In `title_patterns_table` definition, corrected the column reference
4343
- Made `match_pattern_type` searchable
4444
- Corrected the column references and made code consistent on all the other tables, i.e., `exclude_patterns_table`, `include_patterns_table`, `division_patterns_table` and `document_type_patterns_table`
45+
46+
- 1190-add-tests-for-job-generation-pipeline
47+
- Description: Tests have been added to enhance coverage for the config and job creation pipeline, alongside comprehensive tests for XML processing.
48+
- Changes:
49+
- Added config_generation/tests/test_config_generation_pipeline.py which tests the config and job generation pipeline, ensuring all components interact correctly
50+
- config_generation/tests/test_db_to_xml.py is updated to include comprehensive tests for XML Processing

config_generation/tests/test_db_to_xml.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#docker-compose -f local.yml run --rm django pytest config_generation/tests/test_db_to_xml.py
12
from xml.etree.ElementTree import ElementTree, ParseError, fromstring
23

34
import pytest
@@ -84,14 +85,20 @@ def test_add_new_element():
8485
updated_xml = editor.update_config_xml()
8586
assert "Value" in updated_xml and "<newchild>Value</newchild>" in updated_xml
8687

87-
88-
def test_add_complex_element_structure():
88+
def test_add_third_level_hierarchy():
8989
xml_string = "<root></root>"
9090
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")
9292
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"
95102

96103
# Test transformations and generic mapping
97104
def test_convert_indexer_to_scraper_transformation():

0 commit comments

Comments
 (0)