fix old tests (will be removed/updated)

This commit is contained in:
James Woglom
2024-09-30 00:14:16 -04:00
parent ec497d7d00
commit bb3094869d
4 changed files with 47 additions and 53 deletions
+21 -27
View File
@@ -22,7 +22,8 @@ class TestNightscoutEntry(unittest.TestCase):
"created_at": "2021-03-16 00:25:21-04:00",
"carbs": None,
"insulin": None,
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
@@ -41,7 +42,8 @@ class TestNightscoutEntry(unittest.TestCase):
"created_at": "2021-03-16 12:25:21-04:00",
"carbs": None,
"insulin": None,
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
@@ -57,7 +59,8 @@ class TestNightscoutEntry(unittest.TestCase):
"carbs": 45,
"insulin": 7.5,
"notes": "",
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
@@ -72,7 +75,8 @@ class TestNightscoutEntry(unittest.TestCase):
"carbs": 5,
"insulin": 0.5,
"notes": "",
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
@@ -92,7 +96,8 @@ class TestNightscoutEntry(unittest.TestCase):
"notes": "",
"enteredBy": "Pump (tconnectsync)",
"glucose": "123",
"glucoseType": "Sensor"
"glucoseType": "Sensor",
"pump_event_id": ""
}
)
@@ -111,28 +116,14 @@ class TestNightscoutEntry(unittest.TestCase):
"notes": "",
"enteredBy": "Pump (tconnectsync)",
"glucose": "150",
"glucoseType": "Finger"
"glucoseType": "Finger",
"pump_event_id": ""
}
)
def test_bolus_with_bg_invalid_type(self):
self.assertRaises(InvalidBolusTypeException,
NightscoutEntry.bolus,
bolus=0.5,
carbs=5,
created_at="2021-03-16 12:25:21-04:00",
bg="150")
self.assertRaises(InvalidBolusTypeException,
NightscoutEntry.bolus,
bolus=0.5,
carbs=5,
created_at="2021-03-16 12:25:21-04:00",
bg="150",
bg_type="")
self.assertRaises(InvalidBolusTypeException,
NightscoutEntry.bolus,
NightscoutEntry.bolus,
bolus=0.5,
carbs=5,
created_at="2021-03-16 12:25:21-04:00",
@@ -163,9 +154,10 @@ class TestNightscoutEntry(unittest.TestCase):
"date": 1635041834000,
"dateString": "2021-10-23T22:17:14-0400",
"device": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
def test_sitechange(self):
self.assertEqual(
NightscoutEntry.sitechange(
@@ -176,10 +168,11 @@ class TestNightscoutEntry(unittest.TestCase):
"reason": "reason",
"notes": "reason",
"created_at": "2021-12-05T00:16:35.058Z",
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
def test_basalsuspension(self):
self.assertEqual(
NightscoutEntry.basalsuspension(
@@ -190,11 +183,12 @@ class TestNightscoutEntry(unittest.TestCase):
"reason": "reason",
"notes": "reason",
"created_at": "2021-12-05T00:16:35.058Z",
"enteredBy": "Pump (tconnectsync)"
"enteredBy": "Pump (tconnectsync)",
"pump_event_id": ""
}
)
def test_profile_store(self):
self.assertEqual(
NightscoutEntry.profile_store(
+10 -10
View File
@@ -16,7 +16,7 @@ def _stub_last_uploaded_entry(eventType, time_start=None, time_end=None):
class TestNsWritePumpEvents(unittest.TestCase):
SITE_CHANGE_EVENT = {'time': '2024-02-04 16:27:50-05:00', 'event_type': 'Site/Cartridge Change'}
SITE_CHANGE_NS = {'created_at': '2024-02-04 16:27:50-05:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Site Change', 'notes': 'Site/Cartridge Change','reason': 'Site/Cartridge Change'}
SITE_CHANGE_NS = {'created_at': '2024-02-04 16:27:50-05:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Site Change', 'notes': 'Site/Cartridge Change','reason': 'Site/Cartridge Change', 'pump_event_id': ''}
def test_write_single_sitechange_event(self):
nightscout = NightscoutApi()
nightscout.last_uploaded_entry = _stub_last_uploaded_entry
@@ -31,7 +31,7 @@ class TestNsWritePumpEvents(unittest.TestCase):
}, dict(nightscout.uploaded_entries))
EMPTY_CART_EVENT = {'time': '2024-05-14 09:01:59-04:00', 'event_type': 'Empty Cartridge/Pump Shutdown'}
EMPTY_CART_NS = {'created_at': '2024-05-14 09:01:59-04:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Basal Suspension', 'notes': 'Empty Cartridge/Pump Shutdown', 'reason': 'Empty Cartridge/Pump Shutdown'}
EMPTY_CART_NS = {'created_at': '2024-05-14 09:01:59-04:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Basal Suspension', 'notes': 'Empty Cartridge/Pump Shutdown', 'reason': 'Empty Cartridge/Pump Shutdown', 'pump_event_id': ''}
def test_write_single_emptycart_event(self):
nightscout = NightscoutApi()
nightscout.last_uploaded_entry = _stub_last_uploaded_entry
@@ -46,7 +46,7 @@ class TestNsWritePumpEvents(unittest.TestCase):
}, dict(nightscout.uploaded_entries))
USER_SUSPENDED_EVENT = {'time': '2024-02-05 09:48:22-05:00', 'event_type': 'User Suspended'}
USER_SUSPENDED_NS = {'created_at': '2024-02-05 09:48:22-05:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Basal Suspension', 'notes': 'User Suspended', 'reason': 'User Suspended'}
USER_SUSPENDED_NS = {'created_at': '2024-02-05 09:48:22-05:00', 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Basal Suspension', 'notes': 'User Suspended', 'reason': 'User Suspended', 'pump_event_id': ''}
def test_write_single_usersuspended_event(self):
nightscout = NightscoutApi()
nightscout.last_uploaded_entry = _stub_last_uploaded_entry
@@ -59,11 +59,11 @@ class TestNsWritePumpEvents(unittest.TestCase):
self.USER_SUSPENDED_NS
]
}, dict(nightscout.uploaded_entries))
EXERCISE_EVENT = {'time': '2024-03-10 08:53:20-04:00', 'duration_mins': 269.3833333333333, 'event_type': 'Exercise'}
EXERCISE_NS = {'created_at': '2024-03-10 08:53:20-04:00', 'duration': 269.3833333333333, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Exercise', 'notes': 'Exercise', 'reason': 'Exercise'}
EXERCISE_NS = {'created_at': '2024-03-10 08:53:20-04:00', 'duration': 269.3833333333333, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Exercise', 'notes': 'Exercise', 'reason': 'Exercise', 'pump_event_id': ''}
EXERCISE_EXTENDED_EVENT = {'time': '2024-03-10 08:53:20-04:00', 'duration_mins': 585.8833333333333, 'event_type': 'Exercise'}
EXERCISE_EXTENDED_NS = {'created_at': '2024-03-10 08:53:20-04:00', 'duration': 585.8833333333333, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Exercise', 'notes': 'Exercise', 'reason': 'Exercise'}
EXERCISE_EXTENDED_NS = {'created_at': '2024-03-10 08:53:20-04:00', 'duration': 585.8833333333333, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Exercise', 'notes': 'Exercise', 'reason': 'Exercise', 'pump_event_id': ''}
def test_write_exercise_events(self):
nightscout = NightscoutApi()
nightscout.last_uploaded_entry = _stub_last_uploaded_entry
@@ -101,11 +101,11 @@ class TestNsWritePumpEvents(unittest.TestCase):
self.EXERCISE_EXTENDED_NS
]
}, dict(nightscout.uploaded_entries))
SLEEP_EVENT = {'time': '2024-02-07 00:00:19-05:00', 'duration_mins': 13.916666666666666, 'event_type': 'Sleep'}
SLEEP_NS = {'created_at': '2024-02-07 00:00:19-05:00', 'duration': 13.916666666666666, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Sleep', 'notes': 'Sleep', 'reason': 'Sleep'}
SLEEP_NS = {'created_at': '2024-02-07 00:00:19-05:00', 'duration': 13.916666666666666, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Sleep', 'notes': 'Sleep', 'reason': 'Sleep', 'pump_event_id': ''}
SLEEP_EXTENDED_EVENT = {'time': '2024-02-07 00:00:19-05:00', 'duration_mins': 74.0, 'event_type': 'Sleep'}
SLEEP_EXTENDED_NS = {'created_at': '2024-02-07 00:00:19-05:00', 'duration': 74.0, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Sleep', 'notes': 'Sleep', 'reason': 'Sleep'}
SLEEP_EXTENDED_NS = {'created_at': '2024-02-07 00:00:19-05:00', 'duration': 74.0, 'enteredBy': 'Pump (tconnectsync)', 'eventType': 'Sleep', 'notes': 'Sleep', 'reason': 'Sleep', 'pump_event_id': ''}
def test_write_sleep_events(self):
nightscout = NightscoutApi()
nightscout.last_uploaded_entry = _stub_last_uploaded_entry
@@ -143,7 +143,7 @@ class TestNsWritePumpEvents(unittest.TestCase):
self.SLEEP_EXTENDED_NS
]
}, dict(nightscout.uploaded_entries))
if __name__ == '__main__':
unittest.main()
+15 -15
View File
@@ -26,7 +26,7 @@ class TestProcessTimeRange(unittest.TestCase):
def stub_therapy_timeline(self, time_start, time_end):
return copy.deepcopy(TestBasalSync.base)
def stub_ciq_therapy_events(self, time_start, time_end):
return {
"event": []
@@ -39,7 +39,7 @@ class TestProcessTimeRange(unittest.TestCase):
"basalData": [],
"bolusData": []
}
def stub_ws2_basalsuspension(self, time_start, time_end):
return {"BasalSuspension": []}
@@ -394,7 +394,7 @@ class TestProcessTimeRange(unittest.TestCase):
self.assertDictEqual(nightscout.put_entries, {})
self.assertListEqual(nightscout.deleted_entries, [])
self.assertEqual(count, 0)
"""Existing IOB in Nightscout. Uploads new iob reading and deletes old IOB."""
def test_updates_ciq_iob_data(self):
tconnect = TConnectApi()
@@ -442,7 +442,7 @@ class TestProcessTimeRange(unittest.TestCase):
"activity/sentinel_existing_iob_id"
])
self.assertEqual(count, 1)
"""No pump activity events in Nightscout. New CIQ activity events."""
def test_new_ciq_activity_events(self):
tconnect = TConnectApi()
@@ -460,7 +460,7 @@ class TestProcessTimeRange(unittest.TestCase):
"events": [{
"duration": 1200,
"eventType": 2, # Exercise
"continuation": None,
"continuation": None,
"timeZoneId": "America/Los_Angeles",
"x": 1619901912 # 2021-05-01 13:45:12-04:00
}, {
@@ -510,7 +510,7 @@ class TestProcessTimeRange(unittest.TestCase):
"events": [{
"duration": 1200,
"eventType": 2, # Exercise
"continuation": None,
"continuation": None,
"timeZoneId": "America/Los_Angeles",
"x": 1619901912 # 2021-05-01 13:45:12-04:00
}, {
@@ -539,7 +539,7 @@ class TestProcessTimeRange(unittest.TestCase):
self.assertListEqual(nightscout.deleted_entries, [])
self.assertEqual(count, 0)
"""
Existing Sleep event in Nightscout with shorter duration than current, as well as a past Exercise event.
Ensures that the old sleep event is deleted and a new one is created with the correct duration."""
@@ -559,7 +559,7 @@ class TestProcessTimeRange(unittest.TestCase):
"events": [{
"duration": 1200,
"eventType": 2, # Exercise
"continuation": None,
"continuation": None,
"timeZoneId": "America/Los_Angeles",
"x": 1619901912 # 2021-05-01 13:45:12-04:00
}, {
@@ -623,7 +623,7 @@ class TestProcessTimeRange(unittest.TestCase):
tconnect.controliq.therapy_timeline = self.stub_therapy_timeline
tconnect.ws2.therapy_timeline_csv = self.stub_therapy_timeline_csv
def fake_basalsuspension(time_start, time_end):
def fake_basalsuspension(time_start, time_end):
self.assertEqual(time_start, start)
self.assertEqual(time_end, end)
@@ -673,7 +673,7 @@ class TestProcessTimeRange(unittest.TestCase):
tconnect.controliq.therapy_timeline = self.stub_therapy_timeline
tconnect.ws2.therapy_timeline_csv = self.stub_therapy_timeline_csv
def fake_basalsuspension(time_start, time_end):
def fake_basalsuspension(time_start, time_end):
self.assertEqual(time_start, start)
self.assertEqual(time_end, end)
@@ -737,7 +737,7 @@ class TestProcessTimeRange(unittest.TestCase):
tconnect.controliq.therapy_timeline = self.stub_therapy_timeline
tconnect.ws2.therapy_timeline_csv = self.stub_therapy_timeline_csv
def fake_basalsuspension(time_start, time_end):
def fake_basalsuspension(time_start, time_end):
self.assertEqual(time_start, start)
self.assertEqual(time_end, end)
@@ -781,7 +781,7 @@ class TestProcessTimeRange(unittest.TestCase):
pump_guid = '00000000-0000-0000-0000-000000000001'
serial_number = '12345'
def fake_my_devices():
return {
serial_number: Device(
@@ -830,7 +830,7 @@ class TestProcessTimeRange(unittest.TestCase):
pump_guid = '00000000-0000-0000-0000-000000000001'
serial_number = '12345'
def fake_my_devices():
return {
serial_number: Device(
@@ -878,7 +878,7 @@ class TestProcessTimeRange(unittest.TestCase):
pump_guid = '00000000-0000-0000-0000-000000000001'
serial_number = '12345'
def fake_my_devices():
return {
serial_number: Device(
@@ -932,7 +932,7 @@ class TestProcessTimeRange(unittest.TestCase):
pump_guid = '00000000-0000-0000-0000-000000000001'
serial_number = '12345'
def fake_my_devices():
return {
serial_number: Device(