def test_sitechange(self): self.assertEqual( NightscoutEntry.sitechange(created_at="2021-12-05T00:16:35.058Z", reason="reason"), { "eventType": "Site Change", "reason": "reason", "notes": "reason", "created_at": "2021-12-05T00:16:35.058Z", "enteredBy": "Pump (tconnectsync)" })
def test_new_ws2_activity_events(self): tconnect = TConnectApi() # datetimes are unused by the API fake start = datetime.datetime(2021, 5, 1, 0, 0) end = datetime.datetime(2021, 5, 3, 0, 0) 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): self.assertEqual(time_start, start) self.assertEqual(time_end, end) return {"BasalSuspension": [ { 'EventDateTime': '/Date(1638663490000-0000)/', 'SuspendReason': 'site-cart' }, { 'EventDateTime': '/Date(1637863616000-0000)/', 'SuspendReason': 'alarm' }, { 'EventDateTime': '/Date(1638662852000-0000)/', 'SuspendReason': 'manual' } ]} tconnect.ws2.basalsuspension = fake_basalsuspension nightscout = NightscoutApi() nightscout.last_uploaded_entry = self.stub_last_uploaded_entry nightscout.last_uploaded_activity = self.stub_last_uploaded_activity process_time_range(tconnect, nightscout, start, end, pretend=False, features=[PUMP_EVENTS]) self.assertEqual(len(nightscout.uploaded_entries["treatments"]), 3) self.assertDictEqual(dict(nightscout.uploaded_entries), { "treatments": [ NightscoutEntry.sitechange(created_at="2021-12-04 16:18:10-05:00", reason="Site/Cartridge Change"), NightscoutEntry.basalsuspension(created_at="2021-11-25 10:06:56-05:00", reason="Empty Cartridge/Pump Shutdown"), NightscoutEntry.basalsuspension(created_at="2021-12-04 16:07:32-05:00", reason="User Suspended") ]}) self.assertDictEqual(nightscout.put_entries, {}) self.assertListEqual(nightscout.deleted_entries, [])