feat(csv-import): Add blood pressure and activity row diagnosis functionality
- Introduced `diagnose_blood_pressure_row` and `diagnose_activity_row` functions to validate and analyze blood pressure and activity data from CSV imports. - Updated the CSV import logic to handle combined datetime columns for blood pressure and activity, improving data integrity during import. - Enhanced type conversion specifications to include `start_time` for blood pressure and activity, ensuring accurate data mapping. - Added tests to validate the new diagnosis functions and their integration with existing import processes, ensuring robustness and reliability. - Updated frontend messages to provide clearer guidance on blood pressure and activity data handling during CSV imports.
This commit is contained in:
1 parent
c5b0540b11
commit
5b96bd4f75
9 files changed
+295
-9
No files matched your search
@@ -7,6 +7,7 @@ pytest-Lauf mitlaufen.
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import datetime as dt
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
@@ -317,6 +318,49 @@ def test_run_universal_import_weight_two_rows_same_day_last_value():
|
||||
assert params[3] == 83.5
|
||||
|
||||
|
||||
def test_activity_alias_maps_german_workout_wide_columns():
|
||||
from csv_parser.type_converter import build_row_after_mapping
|
||||
|
||||
row = {
|
||||
"Datum/Uhrzeit": "2026-04-03 08:00:00",
|
||||
"Trainingsart": "Laufen",
|
||||
"Dauer": "0:45:00",
|
||||
}
|
||||
fm = {"Workout Type": "activity_type"}
|
||||
tc = {
|
||||
"activity_type": {"type": "string"},
|
||||
"start_time": {"type": "datetime", "format": "yyyy-mm-dd HH:MM:SS", "flexible": True},
|
||||
"duration_min": {
|
||||
"type": "duration",
|
||||
"format": "HH:MM:SS",
|
||||
"target_unit": "minutes",
|
||||
"flexible": True,
|
||||
},
|
||||
}
|
||||
out = build_row_after_mapping(row, fm, tc, module="activity")
|
||||
assert str(out.get("activity_type")) == "Laufen"
|
||||
assert isinstance(out.get("start_time"), dt.datetime)
|
||||
assert out.get("duration_min") == 45.0
|
||||
|
||||
|
||||
def test_blood_pressure_alias_combined_datetime_column():
|
||||
from csv_parser.type_converter import build_row_after_mapping
|
||||
|
||||
row = {
|
||||
"Datum/Uhrzeit": "2026-04-03 10:30:00",
|
||||
"Systolisch (mmHg)": "120",
|
||||
"Diastolisch (mmHg)": "80",
|
||||
}
|
||||
fm = {"Date": "measured_date"}
|
||||
tc = {
|
||||
"systolic": {"type": "int", "flexible": True},
|
||||
"diastolic": {"type": "int", "flexible": True},
|
||||
}
|
||||
out = build_row_after_mapping(row, fm, tc, module="blood_pressure")
|
||||
assert isinstance(out.get("start_time"), dt.datetime)
|
||||
assert int(out.get("systolic")) == 120
|
||||
|
||||
|
||||
def test_diagnose_vitals_row_and_mapping_smoke():
|
||||
fm = {
|
||||
"Datum/Uhrzeit": "date",
|
||||
|
||||
Reference in new issue
Block a user