fix(csv_parser): Normalize header comparison in CSV template validation
- Updated the `validate_csv_template` function to normalize both the column signature and field mappings for accurate comparison, preventing false warnings about mismatches. - Enhanced warning messages to provide clearer guidance on the relationship between normalized signatures and raw field mappings. - Added a new test to ensure that normalized signatures do not trigger false warnings when compared to raw mappings.
This commit is contained in:
1 parent
0629f88b37
commit
ebca44829e
2 files changed
+43
-6
No files matched your search
@@ -30,6 +30,31 @@ def test_validate_invalid_target_error():
|
||||
assert any(e["code"] == "invalid_field_mapping" for e in r["errors"])
|
||||
|
||||
|
||||
def test_signature_normalized_vs_raw_mapping_no_false_warning():
|
||||
"""Analyse liefert normalisierte Signatur; field_mappings nutzt Original-Header wie im Seed."""
|
||||
r = validate_csv_template(
|
||||
"blood_pressure",
|
||||
{
|
||||
"Datum": "measured_date",
|
||||
"Zeit": "measured_time",
|
||||
"Systolisch (mmHg)": "systolic",
|
||||
"Diastolisch (mmHg)": "diastolic",
|
||||
"Puls (bpm)": "pulse",
|
||||
},
|
||||
{
|
||||
"measured_date": {"type": "date", "format": "dd.mm.yyyy"},
|
||||
"measured_time": {"type": "time", "format": "HH:MM"},
|
||||
"systolic": {"type": "int"},
|
||||
"diastolic": {"type": "int"},
|
||||
"pulse": {"type": "int"},
|
||||
},
|
||||
None,
|
||||
["datum", "diastolisch_mmhg", "puls_bpm", "systolisch_mmhg", "zeit"],
|
||||
)
|
||||
assert r["valid"] is True
|
||||
assert not any(w["code"] == "signature_vs_mappings_mismatch" for w in r["warnings"])
|
||||
|
||||
|
||||
def test_validate_duplicate_target_warning():
|
||||
r = validate_csv_template(
|
||||
"weight",
|
||||
|
||||
Reference in new issue
Block a user