Activity and nutrition legacy CSV imports enforce tier limits with UsageBadge UI; Universal CSV gets mapping validation on copy/import, format-check parity, and structured error_details. version: 0.9u module: activity 1.2.1, nutrition 1.0.3, csv_import 0.4.0 Co-authored-by: Cursor <cursoragent@cursor.com>
27 lines
890 B
Python
27 lines
890 B
Python
"""Tests für CSV-Vorlagen-Validierung (#71)."""
|
|
|
|
from csv_parser.template_validator import validate_csv_template
|
|
|
|
|
|
def test_validate_csv_template_rejects_invalid_row_processing():
|
|
report = validate_csv_template(
|
|
"nutrition",
|
|
{"Datum": "date", "kcal": "kcal"},
|
|
None,
|
|
{"group_by": ["date"], "aggregates": {"kcal": "not_an_op"}},
|
|
["Datum", "kcal"],
|
|
)
|
|
assert report["valid"] is False
|
|
assert any(e.get("code") == "invalid_import_row_processing" for e in report["errors"])
|
|
|
|
|
|
def test_validate_csv_template_accepts_nutrition_aggregation():
|
|
report = validate_csv_template(
|
|
"nutrition",
|
|
{"Datum": "date", "kcal": "kcal", "protein": "protein_g"},
|
|
None,
|
|
{"group_by": ["date"], "aggregates": {"kcal": "sum", "protein_g": "sum"}},
|
|
["Datum", "kcal", "protein"],
|
|
)
|
|
assert report["valid"] is True
|