示例#1
0
    def test_bolus_with_bg(self):
        self.assertEqual(
            NightscoutEntry.bolus(bolus=7.5,
                                  carbs=45,
                                  created_at="2021-03-16 00:25:21-04:00",
                                  bg="123",
                                  bg_type=NightscoutEntry.SENSOR),
            {
                "eventType": "Combo Bolus",
                "created_at": "2021-03-16 00:25:21-04:00",
                "carbs": 45,
                "insulin": 7.5,
                "notes": "",
                "enteredBy": "Pump (tconnectsync)",
                "glucose": "123",
                "glucoseType": "Sensor"
            })

        self.assertEqual(
            NightscoutEntry.bolus(bolus=0.5,
                                  carbs=5,
                                  created_at="2021-03-16 12:25:21-04:00",
                                  bg="150",
                                  bg_type=NightscoutEntry.FINGER),
            {
                "eventType": "Combo Bolus",
                "created_at": "2021-03-16 12:25:21-04:00",
                "carbs": 5,
                "insulin": 0.5,
                "notes": "",
                "enteredBy": "Pump (tconnectsync)",
                "glucose": "150",
                "glucoseType": "Finger"
            })
    def test_bolus(self):
        self.assertEqual(
            NightscoutEntry.bolus(
                bolus=7.5,
                carbs=45,
                created_at="2021-03-16 00:25:21-04:00"),
            {
                "eventType": "Combo Bolus",
                "created_at": "2021-03-16 00:25:21-04:00",
                "carbs": 45,
                "insulin": 7.5,
                "notes": "",
                "enteredBy": "Pump (tconnectsync)"
            }
        )

        self.assertEqual(
            NightscoutEntry.bolus(
                bolus=0.5,
                carbs=5,
                created_at="2021-03-16 12:25:21-04:00"),
            {
                "eventType": "Combo Bolus",
                "created_at": "2021-03-16 12:25:21-04:00",
                "carbs": 5,
                "insulin": 0.5,
                "notes": "",
                "enteredBy": "Pump (tconnectsync)"
            }
        )
示例#3
0
    def test_new_ciq_bolus_data(self):
        tconnect = TConnectApi()

        start = datetime.datetime(2021, 4, 20, 12, 0)
        end = datetime.datetime(2021, 4, 21, 12, 0)

        tconnect.controliq.therapy_timeline = self.stub_therapy_timeline

        def fake_therapy_timeline_csv(time_start, time_end):
            return {
                **self.stub_therapy_timeline_csv(time_start, time_end),
                "bolusData":
                TestBolusSync.get_example_csv_bolus_events(),
            }

        tconnect.ws2.therapy_timeline_csv = fake_therapy_timeline_csv

        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)

        pprint.pprint(nightscout.uploaded_entries)
        self.assertEqual(len(nightscout.uploaded_entries["treatments"]), 3)
        self.assertDictEqual(
            dict(nightscout.uploaded_entries), {
                "treatments": [
                    NightscoutEntry.bolus(13.53,
                                          75,
                                          "2021-04-01 12:58:26-04:00",
                                          notes="Standard/Correction"),
                    NightscoutEntry.bolus(1.25,
                                          0,
                                          "2021-04-01 23:23:17-04:00",
                                          notes="Standard (Override)"),
                    NightscoutEntry.bolus(1.7,
                                          0,
                                          "2021-04-02 01:00:47-04:00",
                                          notes="Automatic Bolus/Correction"),
                ]
            })
        self.assertDictEqual(nightscout.put_entries, {})
        self.assertDictEqual(nightscout.deleted_entries, {})
示例#4
0
    def test_new_ciq_bolus_data(self):
        tconnect = TConnectApi()

        # datetimes are unused by the API fake
        start = datetime.datetime(2021, 4, 20, 12, 0)
        end = datetime.datetime(2021, 4, 21, 12, 0)

        tconnect.controliq.therapy_timeline = self.stub_therapy_timeline

        bolusData = TestBolusSync.get_example_csv_bolus_events()
        def fake_therapy_timeline_csv(time_start, time_end):
            return {
                **self.stub_therapy_timeline_csv(time_start, time_end),
                "bolusData": bolusData,
            }

        tconnect.ws2.therapy_timeline_csv = fake_therapy_timeline_csv

        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=[BOLUS, BASAL])

        pprint.pprint(nightscout.uploaded_entries)
        self.assertEqual(len(nightscout.uploaded_entries["treatments"]), len(bolusData))
        self.assertDictEqual(dict(nightscout.uploaded_entries), {
            "treatments": [
                NightscoutEntry.bolus(13.53, 75, "2021-04-01 12:58:26-04:00", notes="Standard/Correction"),
                NightscoutEntry.bolus(1.25, 0, "2021-04-01 23:23:17-04:00", notes="Standard (Override)"),
                NightscoutEntry.bolus(1.7, 0, "2021-04-02 01:00:47-04:00", notes="Automatic Bolus/Correction"),
                NightscoutEntry.bolus(1.82, 0, "2021-09-06 12:24:47-04:00", notes="Standard/Correction (Terminated by Alarm: requested 2.63 units)"),
        ]})
        self.assertDictEqual(nightscout.put_entries, {})
        self.assertListEqual(nightscout.deleted_entries, [])