Download tests/test_xml_parser.py from Surajnitp/flowmarg: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/tests/test_xml_parser.py
- Command line
-
hf download hf://spaces/Surajnitp/flowmarg/tests/test_xml_parser.py
-
curl -L -o test_xml_parser.py https://huggingface.co/spaces/Surajnitp/flowmarg/resolve/main/tests/test_xml_parser.py
1.59 kB
| """ | |
| TEST SUITE - core/xml_parser.py | |
| Tests XML parsing and validation | |
| """ | |
| import pytest | |
| import pandas as pd | |
| from core.xml_parser import ( | |
| parse_station_base, | |
| parse_geometry_report, | |
| alignment_names, | |
| detected_summary, | |
| classify | |
| ) | |
| class TestXMLParser: | |
| """Test XML parser functions""" | |
| def test_classify(self): | |
| assert classify("CL_Existing") == "CL" | |
| assert classify("LH_Track") == "LH" | |
| assert classify("RH_Track") == "RH" | |
| assert classify("Other") == "OTHER" | |
| def test_alignment_names(self): | |
| df = pd.DataFrame({ | |
| "offset_alignment": ["CL_1", "LH_1", "RH_1", "CL_2"] | |
| }) | |
| names = alignment_names(df) | |
| assert len(names) == 4 | |
| assert "CL_1" in names | |
| def test_alignment_names_empty(self): | |
| assert alignment_names(None) == [] | |
| assert alignment_names(pd.DataFrame()) == [] | |
| def test_detected_summary(self): | |
| df = pd.DataFrame({ | |
| "datum_alignment": ["Datum1", "Datum1"], | |
| "offset_alignment": ["CL_1", "LH_1"], | |
| "datum_chainage": [1000.0, 1010.0], | |
| "level_m": [10.0, 10.5] | |
| }) | |
| summary = detected_summary(df) | |
| assert not summary.empty | |
| assert "Alignment" in summary.columns | |
| class TestGeometryReport: | |
| """Test geometry report parsing""" | |
| def test_parse_geometry_report_empty(self): | |
| H, V, E = parse_geometry_report(b"") | |
| assert H.empty | |
| assert V.empty | |
| assert E.empty | |
| if __name__ == "__main__": | |
| pytest.main([__file__, "-v"]) | |