feat: add medicine dose graph plotting and toggle functionality with comprehensive tests
Some checks failed
Build and Push Docker Image / build-and-push (push) Has been cancelled

This commit is contained in:
William Valentin
2025-07-30 13:18:25 -07:00
parent 0a8d27957f
commit d14d19e7d9
6 changed files with 591 additions and 15 deletions

View File

@@ -40,15 +40,17 @@ def sample_dataframe():
'sleep': [4, 3, 5],
'appetite': [3, 4, 2],
'bupropion': [1, 1, 0],
'bupropion_doses': ['', '', ''],
'bupropion_doses': ['2024-01-01 08:00:00:150mg', '2024-01-02 08:00:00:300mg', ''],
'hydroxyzine': [0, 1, 0],
'hydroxyzine_doses': ['', '', ''],
'hydroxyzine_doses': ['', '2024-01-02 20:00:00:25mg', ''],
'gabapentin': [2, 2, 1],
'gabapentin_doses': ['', '', ''],
'gabapentin_doses': ['2024-01-01 12:00:00:100mg|2024-01-01 20:00:00:100mg',
'2024-01-02 12:00:00:100mg|2024-01-02 20:00:00:100mg',
'2024-01-03 12:00:00:100mg'],
'propranolol': [1, 0, 1],
'propranolol_doses': ['', '', ''],
'propranolol_doses': ['2024-01-01 12:00:00:10mg', '', '2024-01-03 12:00:00:20mg'],
'quetiapine': [0, 1, 0],
'quetiapine_doses': ['', '', ''],
'quetiapine_doses': ['', '2024-01-02 22:00:00:50mg', ''],
'note': ['Test note 1', 'Test note 2', '']
})
@@ -72,3 +74,18 @@ def mock_env_vars(monkeypatch):
monkeypatch.setenv("LOG_LEVEL", "DEBUG")
monkeypatch.setenv("LOG_PATH", "/tmp/test_logs")
monkeypatch.setenv("LOG_CLEAR", "False")
@pytest.fixture
def sample_dose_data():
"""Sample dose data for testing dose calculation."""
return {
'standard_format': '2025-07-28 18:59:45:150mg|2025-07-28 19:34:19:75mg', # Should sum to 225
'with_bullets': '• • • • 2025-07-30 07:50:00:300', # Should be 300
'decimal_doses': '2025-07-28 18:59:45:12.5mg|2025-07-28 19:34:19:7.5mg', # Should sum to 20
'no_timestamp': '100mg|50mg', # Should sum to 150
'mixed_format': '• 2025-07-30 22:50:00:10|75mg', # Should sum to 85
'empty_string': '', # Should be 0
'nan_value': 'nan', # Should be 0
'no_units': '2025-07-28 18:59:45:10|2025-07-28 19:34:19:5', # Should sum to 15
}