From f9ecaedf4df38c3ff6da150936138f1cad4b37eb Mon Sep 17 00:00:00 2001 From: James Woglom Date: Mon, 3 May 2021 23:48:26 -0400 Subject: [PATCH] tests/controliq: fix fake access token expiration in tests. remove warns for warnings --- tconnectsync/api/controliq.py | 2 +- tconnectsync/api/ws2.py | 2 +- tconnectsync/process.py | 4 ++-- tconnectsync/sync/bolus.py | 2 +- tests/api/test_controliq.py | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tconnectsync/api/controliq.py b/tconnectsync/api/controliq.py index 69bcd3e..1b7b6c4 100644 --- a/tconnectsync/api/controliq.py +++ b/tconnectsync/api/controliq.py @@ -82,7 +82,7 @@ class ControlIQApi: try: return self._get(endpoint, query) except ApiException as e: - logger.warn("Received ApiException in ControlIQApi with endpoint '%s' (tries %d): %s" % (endpoint, tries, e)) + logger.warning("Received ApiException in ControlIQApi with endpoint '%s' (tries %d): %s" % (endpoint, tries, e)) if tries > 0: raise ApiException(e.status_code, "ControlIQ API HTTP %d on retry #%d: %s", e.status_code, tries, e) diff --git a/tconnectsync/api/ws2.py b/tconnectsync/api/ws2.py index 150d44f..8b642a4 100644 --- a/tconnectsync/api/ws2.py +++ b/tconnectsync/api/ws2.py @@ -68,7 +68,7 @@ class WS2Api: req_text = self.get('therapytimeline2csv/%s/%s/%s?format=csv' % (self.userGuid, startDate, endDate), {}) except ApiException as e: # This seems to occur as some kind of soft rate-limit. - logger.warn("Received ApiException in therapy_timeline_csv: (retry count %d) %s" % (tries, e)) + logger.warning("Received ApiException in therapy_timeline_csv: (retry count %d) %s" % (tries, e)) if e.status_code == 500: sleep_seconds = (tries+1) * 60 logger.error("Retrying in %d seconds after HTTP 500 in therapy_timeline_csv (retry count %d): %s" % (sleep_seconds, tries, e)) diff --git a/tconnectsync/process.py b/tconnectsync/process.py index 17eddaf..81e4fa1 100644 --- a/tconnectsync/process.py +++ b/tconnectsync/process.py @@ -36,7 +36,7 @@ def process_time_range(tconnect, nightscout, time_start, time_end, pretend): # device in the time range which is queried. Since it launched in early 2020, # ignore 404's before February. if e.status_code == 404 and time_start.date() < datetime.date(2020, 2, 1): - logger.warn("Ignoring HTTP 404 for ControlIQ API request before Feb 2020") + logger.warning("Ignoring HTTP 404 for ControlIQ API request before Feb 2020") ciqTherapyTimelineData = None else: raise e @@ -55,7 +55,7 @@ def process_time_range(tconnect, nightscout, time_start, time_end, pretend): logger.debug(readingData[-1]) logger.info("Last CGM reading from t:connect: %s (%s)" % (lastReading, timeago(lastReading))) else: - logger.warn("No last CGM reading is able to be determined") + logger.warning("No last CGM reading is able to be determined") added = 0 diff --git a/tconnectsync/sync/bolus.py b/tconnectsync/sync/bolus.py index 0357f30..66abd24 100644 --- a/tconnectsync/sync/bolus.py +++ b/tconnectsync/sync/bolus.py @@ -22,7 +22,7 @@ def process_bolus_events(bolusdata): # Count non-completed bolus if any insulin was delivered (vs. the amount of insulin requested) parsed["description"] += " (%s)" % parsed["completion"] else: - logger.warn("Skipping non-completed bolus data (was a bolus in progress?): %s parsed: %s" % (b, parsed)) + logger.warning("Skipping non-completed bolus data (was a bolus in progress?): %s parsed: %s" % (b, parsed)) continue bolusEvents.append(parsed) diff --git a/tests/api/test_controliq.py b/tests/api/test_controliq.py index fee38c9..24ed3c1 100644 --- a/tests/api/test_controliq.py +++ b/tests/api/test_controliq.py @@ -70,7 +70,7 @@ class TestControlIQApi(unittest.TestCase): context.headers['Location'] = '/newlocation' context.cookies['UserGUID'] = 'user_guid' context.cookies['accessToken'] = 'access_tok' - context.cookies['accessTokenExpiresAt'] = 'access_tok_expire' + context.cookies['accessTokenExpiresAt'] = '2021-05-04T11:18:08.381Z' return '' m.post('https://tconnect.tandemdiabetes.com/login.aspx?ReturnUrl=%2f', @@ -88,7 +88,7 @@ class TestControlIQApi(unittest.TestCase): self.assertEqual(ciq.userGuid, 'user_guid') self.assertEqual(ciq.accessToken, 'access_tok') - self.assertEqual(ciq.accessTokenExpiresAt, 'access_tok_expire') + self.assertEqual(ciq.accessTokenExpiresAt, '2021-05-04T11:18:08.381Z') def test_login_invalid_credentials(self):