From 0be2bfe371d559c6e50a251d0d850efb600fe9f7 Mon Sep 17 00:00:00 2001 From: Norbert Kwizera Date: Wed, 6 Dec 2023 19:03:02 +0200 Subject: [PATCH] Remove use of pytz --- poetry.lock | 34 +-------------- pyproject.toml | 1 - temba_client/tests.py | 17 ++++---- temba_client/utils.py | 4 +- temba_client/v2/tests.py | 93 ++++++++++++++++++++-------------------- 5 files changed, 59 insertions(+), 90 deletions(-) diff --git a/poetry.lock b/poetry.lock index 33fa6d9..9d0ecf0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry 1.4.2 and should not be changed by hand. +# This file is automatically @generated by Poetry 1.7.1 and should not be changed by hand. [[package]] name = "black" version = "22.12.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -40,7 +39,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "certifi" version = "2023.5.7" description = "Python package for providing Mozilla's CA Bundle." -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -52,7 +50,6 @@ files = [ name = "charset-normalizer" version = "3.1.0" description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." -category = "main" optional = false python-versions = ">=3.7.0" files = [ @@ -137,7 +134,6 @@ files = [ name = "click" version = "8.1.3" description = "Composable command line interface toolkit" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -152,7 +148,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -164,7 +159,6 @@ files = [ name = "coverage" version = "5.5" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" files = [ @@ -229,7 +223,6 @@ toml = ["toml"] name = "idna" version = "3.4" description = "Internationalized Domain Names in Applications (IDNA)" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -241,7 +234,6 @@ files = [ name = "iso8601" version = "0.1.16" description = "Simple module to parse ISO 8601 dates" -category = "main" optional = false python-versions = "*" files = [ @@ -253,7 +245,6 @@ files = [ name = "isort" version = "5.12.0" description = "A Python utility / library to sort Python imports." -category = "dev" optional = false python-versions = ">=3.8.0" files = [ @@ -271,7 +262,6 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -283,7 +273,6 @@ files = [ name = "nose2" version = "0.12.0" description = "unittest2 with plugins, the successor to nose" -category = "dev" optional = false python-versions = "*" files = [ @@ -299,7 +288,6 @@ dev = ["Sphinx", "mock", "sphinx-issues", "sphinx-rtd-theme"] name = "pathspec" version = "0.11.1" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -311,7 +299,6 @@ files = [ name = "platformdirs" version = "3.5.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -323,23 +310,10 @@ files = [ docs = ["furo (>=2023.3.27)", "proselint (>=0.13)", "sphinx (>=6.1.3)", "sphinx-autodoc-typehints (>=1.23,!=1.23.4)"] test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.3.1)", "pytest-cov (>=4)", "pytest-mock (>=3.10)"] -[[package]] -name = "pytz" -version = "2023.3" -description = "World timezone definitions, modern and historical" -category = "main" -optional = false -python-versions = "*" -files = [ - {file = "pytz-2023.3-py2.py3-none-any.whl", hash = "sha256:a151b3abb88eda1d4e34a9814df37de2a80e301e68ba0fd856fb9b46bfbbbffb"}, - {file = "pytz-2023.3.tar.gz", hash = "sha256:1d8ce29db189191fb55338ee6d0387d82ab59f3d00eac103412d64e0ebd0c588"}, -] - [[package]] name = "requests" version = "2.30.0" description = "Python HTTP for Humans." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -361,7 +335,6 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] name = "ruff" version = "0.0.171" description = "An extremely fast Python linter, written in Rust." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -387,7 +360,6 @@ files = [ name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -399,7 +371,6 @@ files = [ name = "typing-extensions" version = "4.5.0" description = "Backported and Experimental Type Hints for Python 3.7+" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -411,7 +382,6 @@ files = [ name = "urllib3" version = "2.0.2" description = "HTTP library with thread-safe connection pooling, file post, and more." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -428,4 +398,4 @@ zstd = ["zstandard (>=0.18.0)"] [metadata] lock-version = "2.0" python-versions = "^3.9" -content-hash = "e6b54c8555ac758fc5b7056fc5c582ac96f830ce5091e62390b3373a6d2a7375" +content-hash = "7051544f72159f5ad51085504b003bcf70bcd791162812bbdd3659d6f922ae26" diff --git a/pyproject.toml b/pyproject.toml index 3a62e68..bf0107f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ repository = "http://github.com/rapidpro/rapidpro-python" [tool.poetry.dependencies] python = "^3.9" -pytz = "*" requests = "^2.25.0" iso8601 = "^0.1.13" diff --git a/temba_client/tests.py b/temba_client/tests.py index 0b8c131..d35c41f 100644 --- a/temba_client/tests.py +++ b/temba_client/tests.py @@ -1,9 +1,8 @@ import codecs -import datetime import json import unittest +from datetime import datetime, timedelta, timezone as tzone, tzinfo -import pytz import requests from requests.structures import CaseInsensitiveDict @@ -79,18 +78,18 @@ def assertRequest(self, mock, method, endpoint, **kwargs): class UtilsTest(TembaTest): - class TestTZ(datetime.tzinfo): + class TestTZ(tzinfo): def utcoffset(self, dt): - return datetime.timedelta(hours=-5) + return timedelta(hours=-5) def test_format_iso8601(self): - d = datetime.datetime(2014, 1, 2, 3, 4, 5, 6, UtilsTest.TestTZ()) + d = datetime(2014, 1, 2, 3, 4, 5, 6, UtilsTest.TestTZ()) self.assertEqual(format_iso8601(d), "2014-01-02T08:04:05.000006Z") # it should return None when no datetime given self.assertIs(format_iso8601(None), None) def test_parse_iso8601(self): - dt = datetime.datetime(2014, 1, 2, 3, 4, 5, 0, pytz.UTC) + dt = datetime(2014, 1, 2, 3, 4, 5, 0, tzone.utc) self.assertEqual(parse_iso8601("2014-01-02T03:04:05.000000Z"), dt) self.assertEqual(parse_iso8601("2014-01-02T03:04:05.000000+00:00"), dt) self.assertEqual(parse_iso8601("2014-01-02T05:04:05.000000+02:00"), dt) @@ -99,7 +98,7 @@ def test_parse_iso8601(self): self.assertEqual(parse_iso8601("2014-01-02T03:04:05"), dt) self.assertEqual(parse_iso8601(None), None) - d = datetime.datetime(2014, 1, 2, 0, 0, 0, 0, pytz.UTC) + d = datetime(2014, 1, 2, 0, 0, 0, 0, tzone.utc) self.assertEqual(parse_iso8601("2014-01-02"), d) @@ -218,7 +217,7 @@ def test_deserialize(self): ) self.assertEqual(obj.foo, "a") self.assertEqual(obj.bar, 123) - self.assertEqual(obj.doh, datetime.datetime(2014, 1, 2, 3, 4, 5, 0, pytz.UTC)) + self.assertEqual(obj.doh, datetime(2014, 1, 2, 3, 4, 5, 0, tzone.utc)) self.assertEqual(obj.gem.zed, "c") self.assertEqual(len(obj.hum), 1) self.assertEqual(obj.hum[0].zed, "b") @@ -237,7 +236,7 @@ def test_serialize(self): obj = TestType.create( foo="a", bar=123, - doh=datetime.datetime(2014, 1, 2, 3, 4, 5, 0, pytz.UTC), + doh=datetime(2014, 1, 2, 3, 4, 5, 0, tzone.utc), gem=TestSubType.create(zed="a"), hum=[TestSubType.create(zed="b")], meh={"a": TestSubType.create(zed="c"), "b": TestSubType.create(zed="d")}, diff --git a/temba_client/utils.py b/temba_client/utils.py index a6720a9..d549fdf 100644 --- a/temba_client/utils.py +++ b/temba_client/utils.py @@ -1,7 +1,7 @@ import json +from datetime import timezone as tzone import iso8601 -import pytz import requests @@ -22,7 +22,7 @@ def format_iso8601(value): if value is None: return None - return str(value.astimezone(pytz.UTC).strftime("%Y-%m-%dT%H:%M:%S.%fZ")) + return str(value.astimezone(tzone.utc).strftime("%Y-%m-%dT%H:%M:%S.%fZ")) def request(method, url, **kwargs): # pragma: no cover diff --git a/temba_client/v2/tests.py b/temba_client/v2/tests.py index f281da9..80cb0b6 100644 --- a/temba_client/v2/tests.py +++ b/temba_client/v2/tests.py @@ -1,8 +1,7 @@ -import datetime import json +from datetime import datetime, timezone as tzone from unittest.mock import patch -import pytz from requests.exceptions import ConnectionError from ..exceptions import ( @@ -125,7 +124,9 @@ def test_retry_on_rate_exceed(self, mock_request): self.assertRaises(TembaRateExceededError, self.client.get_runs().all, retry_on_rate_exceed=True) def test_query_with_transformer(self, mock_request): - mock_request.return_value = MockResponse(200, """{ + mock_request.return_value = MockResponse( + 200, + """{ "next": null, "previous": null, "results": [ @@ -140,14 +141,16 @@ def test_query_with_transformer(self, mock_request): "value_type": "numeric" } ] -}""") +}""", + ) + def convert_old_fields(clazz, item): if clazz == Field: item["name"] = item["label"] item["type"] = "number" if item["value_type"] == "numeric" else item["value_type"] return item - client = TembaClient("example.com", "1234567890", user_agent="test/0.1", transformer=convert_old_fields) + client = TembaClient("example.com", "1234567890", user_agent="test/0.1", transformer=convert_old_fields) results = client.get_fields().all() @@ -176,7 +179,7 @@ def test_get_archives(self, mock_request): self.assertEqual(len(results), 4) self.assertEqual(results[1].archive_type, "message") - self.assertEqual(results[1].start_date, datetime.datetime(2018, 4, 1, 0, 0, tzinfo=pytz.utc)) + self.assertEqual(results[1].start_date, datetime(2018, 4, 1, 0, 0, tzinfo=tzone.utc)) self.assertEqual(results[1].period, "monthly") self.assertEqual(results[1].record_count, 10) self.assertEqual(results[1].size, 23) @@ -186,8 +189,8 @@ def test_get_archives(self, mock_request): self.client.get_archives( archive_type="message", period="daily", - after=datetime.datetime(2018, 1, 1, tzinfo=pytz.utc), - before=datetime.datetime(2018, 5, 1, tzinfo=pytz.utc), + after=datetime(2018, 1, 1, tzinfo=tzone.utc), + before=datetime(2018, 5, 1, tzinfo=tzone.utc), ).all() self.assertRequest( @@ -251,13 +254,13 @@ def test_get_broadcasts(self, mock_request): self.assertEqual(results[0].groups[0].uuid, "04a4752b-0f49-480e-ae60-3a3f2bea485c") self.assertEqual(results[0].groups[0].name, "The A-Team") self.assertEqual(results[0].text, "Hello") - self.assertEqual(results[0].created_on, datetime.datetime(2015, 11, 11, 8, 30, 24, 922024, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 11, 11, 8, 30, 24, 922024, tzone.utc)) # check with all params self.client.get_broadcasts( id=12345, - after=datetime.datetime(2014, 12, 12, 22, 34, 36, 978123, pytz.utc), - before=datetime.datetime(2014, 12, 12, 22, 56, 58, 917123, pytz.utc), + after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), + before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), ).all() self.assertRequest( @@ -282,7 +285,7 @@ def test_get_campaigns(self, mock_request): self.assertEqual(results[0].archived, False) self.assertEqual(results[0].group.uuid, "04a4752b-0f49-480e-ae60-3a3f2bea485c") self.assertEqual(results[0].group.name, "The A-Team") - self.assertEqual(results[0].created_on, datetime.datetime(2014, 6, 23, 9, 34, 12, 866000, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2014, 6, 23, 9, 34, 12, 866000, tzone.utc)) # check with all params self.client.get_campaigns(uuid="09d23a05-47fe-11e4-bfe9-b8f6b119e9ab").all() @@ -310,7 +313,7 @@ def test_get_campaign_events(self, mock_request): self.assertEqual(results[0].message, None) self.assertEqual(results[0].flow.uuid, "70c38f94-ab42-4666-86fd-3c76139110d3") self.assertEqual(results[0].flow.name, "Survey Flow") - self.assertEqual(results[0].created_on, datetime.datetime(2015, 6, 8, 12, 18, 7, 671000, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 6, 8, 12, 18, 7, 671000, tzone.utc)) # check with all params self.client.get_campaign_events(uuid="09d23a05-47fe-11e4-bfe9-b8f6b119e9ab").all() @@ -338,8 +341,8 @@ def test_get_channels(self, mock_request): self.assertEqual(results[0].device.power_status, "STATUS_DISCHARGING") self.assertEqual(results[0].device.power_source, "BATTERY") self.assertEqual(results[0].device.network_type, "WIFI") - self.assertEqual(results[0].last_seen, datetime.datetime(2016, 3, 1, 5, 31, 27, 456000, pytz.utc)) - self.assertEqual(results[0].created_on, datetime.datetime(2014, 6, 23, 9, 34, 12, 866000, pytz.utc)) + self.assertEqual(results[0].last_seen, datetime(2016, 3, 1, 5, 31, 27, 456000, tzone.utc)) + self.assertEqual(results[0].created_on, datetime(2014, 6, 23, 9, 34, 12, 866000, tzone.utc)) # check with all params self.client.get_channels(uuid="09d23a05-47fe-11e4-bfe9-b8f6b119e9ab", address="+250788123123").all() @@ -365,7 +368,7 @@ def test_get_classifiers(self, mock_request): self.assertEqual(results[0].type, "wit") self.assertEqual(results[0].name, "Booking") self.assertEqual(results[0].intents, ["book_flight", "book_car"]) - self.assertEqual(results[0].created_on, datetime.datetime(2015, 6, 8, 12, 18, 7, 671000, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 6, 8, 12, 18, 7, 671000, tzone.utc)) # check with all params self.client.get_classifiers(uuid="09d23a05-47fe-11e4-bfe9-b8f6b119e9ab").all() @@ -389,15 +392,15 @@ def test_get_channel_events(self, mock_request): self.assertEqual(results[0].channel.uuid, "9a8b001e-a913-486c-80f4-1356e23f582e") self.assertEqual(results[0].channel.name, "Nexmo") self.assertEqual(results[0].extra, {"foo": "bar"}) - self.assertEqual(results[0].occurred_on, datetime.datetime(2016, 1, 6, 15, 35, 3, 675716, pytz.utc)) - self.assertEqual(results[0].created_on, datetime.datetime(2016, 1, 6, 15, 33, 0, 813162, pytz.utc)) + self.assertEqual(results[0].occurred_on, datetime(2016, 1, 6, 15, 35, 3, 675716, tzone.utc)) + self.assertEqual(results[0].created_on, datetime(2016, 1, 6, 15, 33, 0, 813162, tzone.utc)) # check with all params self.client.get_channel_events( id=12345, contact="5079cb96-a1d8-4f47-8c87-d8c7bb6ddab9", - after=datetime.datetime(2014, 12, 12, 22, 34, 36, 978123, pytz.utc), - before=datetime.datetime(2014, 12, 12, 22, 56, 58, 917123, pytz.utc), + after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), + before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), ).all() self.assertRequest( @@ -433,8 +436,8 @@ def test_get_contacts(self, mock_request): self.assertEqual(results[0].status, "active") self.assertIsNone(results[0].flow) self.assertIsNone(results[0].last_seen_on) - self.assertEqual(results[0].created_on, datetime.datetime(2015, 11, 11, 8, 30, 24, 922024, pytz.utc)) - self.assertEqual(results[0].modified_on, datetime.datetime(2015, 11, 11, 8, 30, 25, 525936, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 11, 11, 8, 30, 24, 922024, tzone.utc)) + self.assertEqual(results[0].modified_on, datetime(2015, 11, 11, 8, 30, 25, 525936, tzone.utc)) # check with all params self.client.get_contacts( @@ -442,8 +445,8 @@ def test_get_contacts(self, mock_request): urn="tel:+250973635665", group="Customers", deleted=False, - after=datetime.datetime(2014, 12, 12, 22, 34, 36, 978123, pytz.utc), - before=datetime.datetime(2014, 12, 12, 22, 56, 58, 917123, pytz.utc), + after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), + before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), reverse=False, ).all() @@ -521,7 +524,7 @@ def test_get_flows(self, mock_request): self.assertEqual(results[0].labels[0].uuid, "5a4eb79e-1b1f-4ae3-8700-09384cca385f") self.assertEqual(results[0].labels[0].name, "Important") self.assertEqual(results[0].expires, 600) - self.assertEqual(results[0].created_on, datetime.datetime(2014, 6, 23, 9, 34, 12, 866000, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2014, 6, 23, 9, 34, 12, 866000, tzone.utc)) self.assertEqual(results[0].runs.active, 56) self.assertEqual(results[0].runs.completed, 123) self.assertEqual(results[0].runs.interrupted, 2) @@ -561,8 +564,8 @@ def test_get_flow_starts(self, mock_request): self.assertEqual(results[0].restart_participants, True) self.assertEqual(results[0].status, "pending") self.assertEqual(results[0].params, {"day": "Monday"}) - self.assertEqual(results[0].created_on, datetime.datetime(2015, 8, 26, 10, 4, 9, 737686, pytz.utc)) - self.assertEqual(results[0].modified_on, datetime.datetime(2015, 9, 26, 10, 4, 9, 737686, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 8, 26, 10, 4, 9, 737686, tzone.utc)) + self.assertEqual(results[0].modified_on, datetime(2015, 9, 26, 10, 4, 9, 737686, tzone.utc)) # check with all params self.client.get_flow_starts(uuid="93a624ad-5440-415e-b49f-17bf42754acb").all() @@ -582,7 +585,7 @@ def test_get_globals(self, mock_request): self.assertEqual(results[0].key, "org_name") self.assertEqual(results[0].name, "Org Name") self.assertEqual(results[0].value, "Acme Ltd") - self.assertEqual(results[0].modified_on, datetime.datetime(2015, 6, 8, 12, 18, 7, 671000, pytz.utc)) + self.assertEqual(results[0].modified_on, datetime(2015, 6, 8, 12, 18, 7, 671000, tzone.utc)) def test_get_groups(self, mock_request): # check no params @@ -653,8 +656,8 @@ def test_get_messages(self, mock_request): self.assertEqual(results[0].attachments, []) self.assertEqual(results[0].flow.uuid, "6ca413c7-bc3a-42cb-9744-6938f791bc36") self.assertEqual(results[0].flow.name, "Registration") - self.assertEqual(results[0].created_on, datetime.datetime(2016, 1, 6, 15, 33, 0, 813162, pytz.utc)) - self.assertEqual(results[0].sent_on, datetime.datetime(2016, 1, 6, 15, 35, 3, 675716, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2016, 1, 6, 15, 33, 0, 813162, tzone.utc)) + self.assertEqual(results[0].sent_on, datetime(2016, 1, 6, 15, 35, 3, 675716, tzone.utc)) self.assertEqual(results[0].modified_on, None) self.assertEqual(results[1].labels[0].uuid, "683c00e2-c130-4b40-9be9-e78c3370e583") @@ -670,8 +673,8 @@ def test_get_messages(self, mock_request): contact="d33e9ad5-5c35-414c-abd4-e7451c69ff1d", folder="inbox", label="Spam", - after=datetime.datetime(2014, 12, 12, 22, 34, 36, 978123, pytz.utc), - before=datetime.datetime(2014, 12, 12, 22, 56, 58, 917123, pytz.utc), + after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), + before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), ).all() self.assertRequest( @@ -714,8 +717,8 @@ def test_get_resthooks(self, mock_request): self.assertEqual(len(results), 2) self.assertEqual(results[0].resthook, "new-mother") - self.assertEqual(results[0].created_on, datetime.datetime(2015, 8, 26, 10, 4, 9, 737686, pytz.utc)) - self.assertEqual(results[0].modified_on, datetime.datetime(2015, 9, 26, 10, 4, 9, 737686, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 8, 26, 10, 4, 9, 737686, tzone.utc)) + self.assertEqual(results[0].modified_on, datetime(2015, 9, 26, 10, 4, 9, 737686, tzone.utc)) def test_get_resthook_events(self, mock_request): # check no params @@ -729,7 +732,7 @@ def test_get_resthook_events(self, mock_request): self.assertEqual(results[0].resthook, "new-mother") self.assertEqual(results[0].data, {"foo": "bar"}) - self.assertEqual(results[0].created_on, datetime.datetime(2015, 8, 26, 10, 4, 9, 737686, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 8, 26, 10, 4, 9, 737686, tzone.utc)) # check with all params self.client.get_resthook_events(resthook="new-mother").all() @@ -749,7 +752,7 @@ def test_get_resthook_subscribers(self, mock_request): self.assertEqual(results[0].id, 1001) self.assertEqual(results[0].resthook, "new-mother") self.assertEqual(results[0].target_url, "http://foo.bar/mothers") - self.assertEqual(results[0].created_on, datetime.datetime(2015, 8, 26, 10, 4, 9, 737686, pytz.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 8, 26, 10, 4, 9, 737686, tzone.utc)) # check with all params self.client.get_resthook_subscribers(id=1001, resthook="new-mother").all() @@ -776,23 +779,21 @@ def test_get_runs(self, mock_request): self.assertEqual(results[0].responded, True) self.assertEqual(len(results[0].path), 4) self.assertEqual(results[0].path[0].node, "27a86a1b-6cc4-4ae3-b73d-89650966a82f") - self.assertEqual(results[0].path[0].time, datetime.datetime(2015, 11, 11, 13, 5, 50, 457742, pytz.utc)) + self.assertEqual(results[0].path[0].time, datetime(2015, 11, 11, 13, 5, 50, 457742, tzone.utc)) self.assertEqual(len(results[0].values), 2) self.assertEqual(results[0].values["color"].value, "blue") self.assertEqual(results[0].values["color"].category, "Blue") self.assertEqual(results[0].values["color"].input, "it is blue") self.assertEqual(results[0].values["color"].name, "color") self.assertEqual(results[0].values["color"].node, "fc32aeb0-ac3e-42a8-9ea7-10248fdf52a1") - self.assertEqual(results[0].values["color"].time, datetime.datetime(2015, 11, 11, 13, 3, 51, 635662, pytz.utc)) + self.assertEqual(results[0].values["color"].time, datetime(2015, 11, 11, 13, 3, 51, 635662, tzone.utc)) self.assertEqual(results[0].values["reason"].value, "Because it's the color of sky") self.assertEqual(results[0].values["reason"].category, "All Responses") self.assertEqual(results[0].values["reason"].node, "4c9cb68d-474f-4b9a-b65e-c2aa593a3466") - self.assertEqual( - results[0].values["reason"].time, datetime.datetime(2015, 11, 11, 13, 5, 57, 576056, pytz.utc) - ) - self.assertEqual(results[0].created_on, datetime.datetime(2015, 8, 26, 10, 4, 9, 737686, pytz.utc)) - self.assertEqual(results[0].modified_on, datetime.datetime(2015, 8, 26, 10, 5, 47, 516562, pytz.utc)) - self.assertEqual(results[0].exited_on, datetime.datetime(2015, 8, 26, 10, 5, 47, 516562, pytz.utc)) + self.assertEqual(results[0].values["reason"].time, datetime(2015, 11, 11, 13, 5, 57, 576056, tzone.utc)) + self.assertEqual(results[0].created_on, datetime(2015, 8, 26, 10, 4, 9, 737686, tzone.utc)) + self.assertEqual(results[0].modified_on, datetime(2015, 8, 26, 10, 5, 47, 516562, tzone.utc)) + self.assertEqual(results[0].exited_on, datetime(2015, 8, 26, 10, 5, 47, 516562, tzone.utc)) self.assertEqual(results[0].exit_type, "completed") self.assertEqual(query.first().uuid, results[0].uuid) @@ -804,8 +805,8 @@ def test_get_runs(self, mock_request): flow="ffce0fbb-4fe1-4052-b26a-91beb2ebae9a", contact="d33e9ad5-5c35-414c-abd4-e7451c69ff1d", responded=True, - after=datetime.datetime(2014, 12, 12, 22, 34, 36, 978123, pytz.utc), - before=datetime.datetime(2014, 12, 12, 22, 56, 58, 917123, pytz.utc), + after=datetime(2014, 12, 12, 22, 34, 36, 978123, tzone.utc), + before=datetime(2014, 12, 12, 22, 56, 58, 917123, tzone.utc), reverse=False, paths=True, ).all()