def test_process_bolus_events_cgmevents_not_matching(self): bolusData = [ TestTConnectEntryBolus.entryStdCorrection, TestTConnectEntryBolus.entryStd, TestTConnectEntryBolus.entryStdAutomatic ] cgmEvents = [ TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry1), TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry2), TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry3) ] bolusEvents = process_bolus_events(bolusData, cgmEvents=cgmEvents) self.assertEqual(len(bolusEvents), len(bolusData)) def set_bg_type(entry, type): entry["bg_type"] = type return entry # Expect FINGER for bolus entries with a BG because there's no matching event with the same BG expected = [ set_bg_type(TConnectEntry.parse_bolus_entry(bolusData[0]), NightscoutEntry.FINGER), set_bg_type(TConnectEntry.parse_bolus_entry(bolusData[1]), NightscoutEntry.FINGER), # No BG specified for the automatic bolus TConnectEntry.parse_bolus_entry(bolusData[2]) ] self.assertListEqual(bolusEvents, expected)
def test_process_cgm_events(self): rawReadings = [ TestTConnectEntryReading.entry1, TestTConnectEntryReading.entry2, TestTConnectEntryReading.entry3, TestTConnectEntryReading.entry4 ] self.assertListEqual( process_cgm_events(rawReadings), [TConnectEntry.parse_reading_entry(r) for r in rawReadings])
def test_parse_reading_entry4(self): self.assertEqual( TConnectEntry.parse_reading_entry(self.entry4), { "time": "2021-10-23 16:25:52-04:00", "bg": "107", "type": "EGV" } )
def test_parse_reading_entry1(self): self.assertEqual( TConnectEntry.parse_reading_entry(self.entry1), { "time": "2021-10-23 12:55:53-04:00", "bg": "135", "type": "EGV" } )
class TestFindEventAt(unittest.TestCase): readingData = [ TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry1), TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry2), TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry3), TConnectEntry.parse_reading_entry(TestTConnectEntryReading.entry4) ] def test_find_event_at_exact(self): for r in self.readingData: self.assertEqual(find_event_at(self.readingData, r["time"]), r) def test_find_event_at_before_not_found(self): self.assertEqual( find_event_at(self.readingData, "2021-10-22 10:30:00-04:00"), None) def test_find_event_at_large_gap(self): self.assertEqual( find_event_at(self.readingData, "2021-10-23 13:30:00-04:00"), self.readingData[0]) def test_find_event_at_between_close(self): self.assertEqual( find_event_at(self.readingData, "2021-10-23 16:17:52-04:00"), self.readingData[1]) self.assertEqual( find_event_at(self.readingData, "2021-10-23 16:21:52-04:00"), self.readingData[2]) self.assertEqual( find_event_at(self.readingData, "2021-10-23 16:25:59-04:00"), self.readingData[3]) def test_find_event_at_most_recent(self): self.assertEqual( find_event_at(self.readingData, "2021-10-23 18:00:00-04:00"), self.readingData[3])