feat(csv-import): Enhance CSV import processing and validation
- Updated the CSV import logic to support new row processing specifications for weight and vitals baseline, allowing for better data aggregation and validation. - Implemented handling for multiple rows on the same day, enabling aggregation of values such as averages for vitals and last values for weight. - Enhanced test coverage for the new import functionalities, ensuring correct behavior during data processing and validation. - Refactored the module registry to include default import row processing options for better flexibility in handling CSV data.
This commit is contained in:
1 parent
c0fcdea1fe
commit
e35d167055
5 files changed
+165
-9
No files matched your search
@@ -65,3 +65,24 @@ def test_resolve_none_uses_nutrition_default():
|
||||
spec = resolve_import_row_processing("nutrition", {})
|
||||
assert spec is not None
|
||||
assert "date" in (spec.get("group_by") or [])
|
||||
|
||||
|
||||
def test_resolve_weight_default_uses_last():
|
||||
spec = resolve_import_row_processing("weight", {})
|
||||
assert spec is not None
|
||||
assert spec.get("aggregates", {}).get("weight") == "last"
|
||||
assert spec.get("aggregates", {}).get("note") == "last"
|
||||
|
||||
|
||||
def test_validate_weight_import_row_processing_ok():
|
||||
validate_import_row_processing(
|
||||
"weight",
|
||||
{"group_by": ["date"], "aggregates": {"weight": "mean"}},
|
||||
{"D": "date", "W": "weight"},
|
||||
)
|
||||
|
||||
|
||||
def test_resolve_vitals_baseline_default_uses_mean():
|
||||
spec = resolve_import_row_processing("vitals_baseline", {})
|
||||
assert spec is not None
|
||||
assert spec.get("aggregates", {}).get("resting_hr") == "mean"
|
||||
Reference in new issue
Block a user