From 2e0120fdfc1c85638ba31bdd38d40f9515d74d58 Mon Sep 17 00:00:00 2001 From: James Woglom Date: Thu, 18 Mar 2021 01:42:44 -0400 Subject: [PATCH] tests: add first test for basal processing --- tests/__init__.py | 0 tests/sync/__init__.py | 0 tests/sync/test_basal.py | 59 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 tests/__init__.py create mode 100644 tests/sync/__init__.py create mode 100644 tests/sync/test_basal.py diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/sync/__init__.py b/tests/sync/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/sync/test_basal.py b/tests/sync/test_basal.py new file mode 100644 index 0000000..f5dcc0a --- /dev/null +++ b/tests/sync/test_basal.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 + +import unittest +from tconnectsync.sync.basal import process_ciq_basal_events +from tconnectsync.parser import TConnectEntry + +class TestBasalSync(unittest.TestCase): + base = { + "basal": { + "profileRates": [], + "tempDeliveryEvents": [], + "algorithmDeliveryEvents": [], + "profileDeliveryEvents": [] + }, + "events": [], + "suspensionDeliveryEvents": [], + "softwareUpdates": [], + "pumpFeatures": [] + } + + def test_process_ciq_basal_events(self): + data = {**self.base} + data["basal"]["tempDeliveryEvents"] = [ + { + "y": 0.8, + "duration": 1221, + "x": 1615878000 + } + ] + data["basal"]["algorithmDeliveryEvents"] = [ + { + "y": 0.797, + "duration": 300, + "x": 1615879521 + } + ] + data["basal"]["profileDeliveryEvents"] = [ + { + "y": 0.799, + "duration": 300, + "x": 1615879221 + } + ] + + basalEvents = process_ciq_basal_events(self.base) + self.assertEqual(len(basalEvents), 3) + + self.assertEqual(basalEvents[0], TConnectEntry.parse_ciq_basal_entry( + data["basal"]["tempDeliveryEvents"][0], delivery_type="tempDelivery")) + + self.assertEqual(basalEvents[1], TConnectEntry.parse_ciq_basal_entry( + data["basal"]["profileDeliveryEvents"][0], delivery_type="profileDelivery")) + + self.assertEqual(basalEvents[2], TConnectEntry.parse_ciq_basal_entry( + data["basal"]["algorithmDeliveryEvents"][0], delivery_type="algorithmDelivery")) + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file