mirror of
https://github.com/bckelley/tconnectsync.git
synced 2026-08-24 03:34:12 -05:00
tests/sync: complete basal ciq process test
This commit is contained in:
@@ -13,7 +13,8 @@ from ..parser.tconnect import TConnectEntry
|
|||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Merges together input from the therapy timeline API into a digestable format of basal data.
|
Merges together input from the therapy timeline API
|
||||||
|
into a digestable format of basal data.
|
||||||
"""
|
"""
|
||||||
def process_ciq_basal_events(data):
|
def process_ciq_basal_events(data):
|
||||||
if data is None:
|
if data is None:
|
||||||
@@ -43,7 +44,8 @@ def process_ciq_basal_events(data):
|
|||||||
return basalEvents
|
return basalEvents
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Processes basal data input from the therapy timeline CSV (which only exists for pre Control-IQ data) into a digestable format.
|
Processes basal data input from the therapy timeline CSV (which only
|
||||||
|
exists for pre Control-IQ data) into a digestable format.
|
||||||
"""
|
"""
|
||||||
def add_csv_basal_events(basalEvents, data):
|
def add_csv_basal_events(basalEvents, data):
|
||||||
last_entry = {}
|
last_entry = {}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class TestBasalSync(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def test_process_ciq_basal_events(self):
|
def test_process_ciq_basal_events(self):
|
||||||
data = {**self.base}
|
data = self.base.copy()
|
||||||
data["basal"]["tempDeliveryEvents"] = [
|
data["basal"]["tempDeliveryEvents"] = [
|
||||||
{
|
{
|
||||||
"y": 0.8,
|
"y": 0.8,
|
||||||
@@ -32,7 +32,12 @@ class TestBasalSync(unittest.TestCase):
|
|||||||
"y": 0.797,
|
"y": 0.797,
|
||||||
"duration": 300,
|
"duration": 300,
|
||||||
"x": 1615879521
|
"x": 1615879521
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
"y": 0,
|
||||||
|
"duration": 2693,
|
||||||
|
"x": 1615879821
|
||||||
|
},
|
||||||
]
|
]
|
||||||
data["basal"]["profileDeliveryEvents"] = [
|
data["basal"]["profileDeliveryEvents"] = [
|
||||||
{
|
{
|
||||||
@@ -42,18 +47,33 @@ class TestBasalSync(unittest.TestCase):
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
basalEvents = process_ciq_basal_events(self.base)
|
data["suspensionDeliveryEvents"] = [
|
||||||
self.assertEqual(len(basalEvents), 3)
|
{
|
||||||
|
"suspendReason": "control-iq",
|
||||||
|
"continuation": None,
|
||||||
|
"x": 1615879821
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
basalEvents = process_ciq_basal_events(data)
|
||||||
|
self.assertEqual(len(basalEvents), 4)
|
||||||
|
|
||||||
self.assertEqual(basalEvents[0], TConnectEntry.parse_ciq_basal_entry(
|
self.assertEqual(basalEvents[0], TConnectEntry.parse_ciq_basal_entry(
|
||||||
data["basal"]["tempDeliveryEvents"][0], delivery_type="tempDelivery"))
|
data["basal"]["tempDeliveryEvents"][0], delivery_type="tempDelivery"))
|
||||||
|
|
||||||
self.assertEqual(basalEvents[1], TConnectEntry.parse_ciq_basal_entry(
|
self.assertEqual(basalEvents[1], TConnectEntry.parse_ciq_basal_entry(
|
||||||
data["basal"]["profileDeliveryEvents"][0], delivery_type="profileDelivery"))
|
data["basal"]["profileDeliveryEvents"][0], delivery_type="profileDelivery"))
|
||||||
|
|
||||||
self.assertEqual(basalEvents[2], TConnectEntry.parse_ciq_basal_entry(
|
self.assertEqual(basalEvents[2], TConnectEntry.parse_ciq_basal_entry(
|
||||||
data["basal"]["algorithmDeliveryEvents"][0], delivery_type="algorithmDelivery"))
|
data["basal"]["algorithmDeliveryEvents"][0], delivery_type="algorithmDelivery"))
|
||||||
|
|
||||||
|
self.assertEqual(basalEvents[3], {
|
||||||
|
"suspendReason": "control-iq",
|
||||||
|
**TConnectEntry.parse_ciq_basal_entry(
|
||||||
|
data["basal"]["algorithmDeliveryEvents"][1],
|
||||||
|
delivery_type="algorithmDelivery")
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
Reference in New Issue
Block a user