Skip to content

Commit 64e161e

Browse files
committed
process_data test columns rename
1 parent 004e143 commit 64e161e

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/test_process_data.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,29 @@ def test_process_data_glucose_warnings():
218218
assert any("above 500" in msg for msg in warning_messages)
219219

220220

221+
def test_process_data_column_rename():
222+
"""Test for column name renaming."""
223+
data = pd.DataFrame({
224+
'subject': ['A', 'A'],
225+
'datetime': ['2020-01-01 10:00:00', '2020-01-01 10:05:00'],
226+
'glucose': [120, 130]
227+
})
228+
229+
result = iglu.process_data(data, id='subject', timestamp='datetime', glu='glucose')
230+
231+
# Check column names and order
232+
assert list(result.columns) == ['id', 'time', 'gl']
233+
234+
# Check data types
235+
assert pd.api.types.is_string_dtype(result['id'])
236+
assert pd.api.types.is_datetime64_any_dtype(result['time'])
237+
assert pd.api.types.is_numeric_dtype(result['gl'])
238+
239+
# Check values were preserved
240+
assert all(result['id'] == 'A')
241+
assert result['gl'].tolist() == [120, 130]
242+
243+
221244
def test_process_data_column_not_found_errors():
222245
"""Test error handling for missing columns."""
223246
data = pd.DataFrame({

0 commit comments

Comments
 (0)