From 887fa746aec17e673e418d96f2e8476194c38de5 Mon Sep 17 00:00:00 2001 From: Sampath Priyankara Date: Thu, 7 Sep 2017 10:40:49 +0900 Subject: [PATCH] iso8601.is8601.Utc No Longer Exists iso8601.UTC is correct datetime UTC field object. iso8601 >= 0.1.12 includes only iso8601.UTC for python3 while both UTC and Utc() for python2. Less then 0.1.12 included both UTC and Utc() for both python2/3. Change-Id: I0f8796fba6725eea013b3f8d9ad33c10a402c524 Closes-Bug: #1715486 --- watcher/objects/utils.py | 2 +- watcher/tests/objects/test_action.py | 8 ++++---- watcher/tests/objects/test_action_description.py | 6 +++--- watcher/tests/objects/test_action_plan.py | 10 +++++----- watcher/tests/objects/test_audit.py | 12 ++++++------ watcher/tests/objects/test_audit_template.py | 6 +++--- watcher/tests/objects/test_goal.py | 6 +++--- watcher/tests/objects/test_objects.py | 2 +- watcher/tests/objects/test_scoring_engine.py | 6 +++--- watcher/tests/objects/test_service.py | 6 +++--- 10 files changed, 32 insertions(+), 32 deletions(-) diff --git a/watcher/objects/utils.py b/watcher/objects/utils.py index 1146832ec..ae9b0be29 100644 --- a/watcher/objects/utils.py +++ b/watcher/objects/utils.py @@ -41,7 +41,7 @@ def datetime_or_none(value, tzinfo_aware=False): # NOTE(danms): Legacy objects from sqlalchemy are stored in UTC, # but are returned without a timezone attached. # As a transitional aid, assume a tz-naive object is in UTC. - value = value.replace(tzinfo=iso8601.iso8601.Utc()) + value = value.replace(tzinfo=iso8601.UTC) elif not tzinfo_aware: value = value.replace(tzinfo=None) diff --git a/watcher/tests/objects/test_action.py b/watcher/tests/objects/test_action.py index 82c6706e3..1b27dda60 100644 --- a/watcher/tests/objects/test_action.py +++ b/watcher/tests/objects/test_action.py @@ -136,7 +136,7 @@ class TestActionObject(base.DbTestCase): action.save() expected_update_at = fake_saved_action['updated_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) mock_get_action.assert_called_once_with( self.context, uuid, eager=self.eager) @@ -181,7 +181,7 @@ class TestCreateDeleteActionObject(base.DbTestCase): action.create() expected_action = self.fake_action.copy() expected_action['created_at'] = expected_action['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) mock_create_action.assert_called_once_with(expected_action) self.assertEqual(self.context, action._context) @@ -201,9 +201,9 @@ class TestCreateDeleteActionObject(base.DbTestCase): expected_action = fake_deleted_action.copy() expected_action['created_at'] = expected_action['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) expected_action['deleted_at'] = expected_action['deleted_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) del expected_action['action_plan'] uuid = self.fake_action['uuid'] diff --git a/watcher/tests/objects/test_action_description.py b/watcher/tests/objects/test_action_description.py index 98b571d3e..91dba2158 100644 --- a/watcher/tests/objects/test_action_description.py +++ b/watcher/tests/objects/test_action_description.py @@ -60,7 +60,7 @@ class TestActionDescriptionObject(base.DbTestCase): action_desc.create() expected_action_desc = self.fake_action_desc.copy() expected_action_desc['created_at'] = expected_action_desc[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) mock_create_action_desc.assert_called_once_with(expected_action_desc) self.assertEqual(self.context, action_desc._context) @@ -107,9 +107,9 @@ class TestActionDescriptionObject(base.DbTestCase): expected_action_desc = fake_deleted_action_desc.copy() expected_action_desc['created_at'] = expected_action_desc[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) expected_action_desc['deleted_at'] = expected_action_desc[ - 'deleted_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'deleted_at'].replace(tzinfo=iso8601.UTC) _id = self.fake_action_desc['id'] action_desc = objects.ActionDescription.get(self.context, _id) diff --git a/watcher/tests/objects/test_action_plan.py b/watcher/tests/objects/test_action_plan.py index a06c94813..b807e0bfe 100644 --- a/watcher/tests/objects/test_action_plan.py +++ b/watcher/tests/objects/test_action_plan.py @@ -139,10 +139,10 @@ class TestActionPlanObject(base.DbTestCase): expected_action_plan = fake_saved_action_plan.copy() expected_action_plan[ 'created_at'] = expected_action_plan['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) expected_action_plan[ 'updated_at'] = expected_action_plan['updated_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) uuid = self.fake_action_plan['uuid'] action_plan = objects.ActionPlan.get_by_uuid( @@ -207,7 +207,7 @@ class TestCreateDeleteActionPlanObject(base.DbTestCase): action_plan.create() expected_action_plan = self.fake_action_plan.copy() expected_action_plan['created_at'] = expected_action_plan[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) mock_create_action_plan.assert_called_once_with(expected_action_plan) self.assertEqual(self.context, action_plan._context) @@ -239,9 +239,9 @@ class TestCreateDeleteActionPlanObject(base.DbTestCase): m_soft_delete_action_plan.return_value = fake_deleted_action_plan expected_action_plan = fake_deleted_action_plan.copy() expected_action_plan['created_at'] = expected_action_plan[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) expected_action_plan['deleted_at'] = expected_action_plan[ - 'deleted_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'deleted_at'].replace(tzinfo=iso8601.UTC) del expected_action_plan['audit'] del expected_action_plan['strategy'] diff --git a/watcher/tests/objects/test_audit.py b/watcher/tests/objects/test_audit.py index 0b0148009..4537802d0 100644 --- a/watcher/tests/objects/test_audit.py +++ b/watcher/tests/objects/test_audit.py @@ -130,9 +130,9 @@ class TestAuditObject(base.DbTestCase): expected_audit = fake_saved_audit.copy() expected_audit['created_at'] = expected_audit['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) expected_audit['updated_at'] = expected_audit['updated_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) uuid = self.fake_audit['uuid'] audit = objects.Audit.get_by_uuid(self.context, uuid, eager=self.eager) @@ -193,7 +193,7 @@ class TestCreateDeleteAuditObject(base.DbTestCase): audit.create() expected_audit = self.fake_audit.copy() expected_audit['created_at'] = expected_audit['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) mock_create_audit.assert_called_once_with(expected_audit) self.assertEqual(self.context, audit._context) @@ -210,9 +210,9 @@ class TestCreateDeleteAuditObject(base.DbTestCase): expected_audit = fake_deleted_audit.copy() expected_audit['created_at'] = expected_audit['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) expected_audit['deleted_at'] = expected_audit['deleted_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) del expected_audit['goal'] del expected_audit['strategy'] @@ -308,7 +308,7 @@ class TestAuditObjectSendNotifications(base.DbTestCase): fake_deleted_audit['deleted_at'] = datetime.datetime.utcnow() expected_audit = fake_deleted_audit.copy() expected_audit['deleted_at'] = expected_audit['deleted_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) m_soft_delete_audit.return_value = fake_deleted_audit m_update_audit.return_value = fake_deleted_audit diff --git a/watcher/tests/objects/test_audit_template.py b/watcher/tests/objects/test_audit_template.py index 14da9f026..3b340016d 100644 --- a/watcher/tests/objects/test_audit_template.py +++ b/watcher/tests/objects/test_audit_template.py @@ -177,7 +177,7 @@ class TestCreateDeleteAuditTemplateObject(base.DbTestCase): audit_template.create() expected_audit_template = self.fake_audit_template.copy() expected_audit_template['created_at'] = expected_audit_template[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) mock_create_audit_template.assert_called_once_with( expected_audit_template) self.assertEqual(self.context, audit_template._context) @@ -193,9 +193,9 @@ class TestCreateDeleteAuditTemplateObject(base.DbTestCase): expected_audit_template = fake_deleted_audit_template.copy() expected_audit_template['created_at'] = expected_audit_template[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) expected_audit_template['deleted_at'] = expected_audit_template[ - 'deleted_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'deleted_at'].replace(tzinfo=iso8601.UTC) del expected_audit_template['goal'] del expected_audit_template['strategy'] diff --git a/watcher/tests/objects/test_goal.py b/watcher/tests/objects/test_goal.py index 26c69515c..fc3914f6b 100644 --- a/watcher/tests/objects/test_goal.py +++ b/watcher/tests/objects/test_goal.py @@ -71,7 +71,7 @@ class TestGoalObject(base.DbTestCase): goal.create() expected_goal = self.fake_goal.copy() expected_goal['created_at'] = expected_goal['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) mock_create_goal.assert_called_once_with(expected_goal) self.assertEqual(self.context, goal._context) @@ -130,9 +130,9 @@ class TestGoalObject(base.DbTestCase): expected_goal = fake_deleted_goal.copy() expected_goal['created_at'] = expected_goal['created_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) expected_goal['deleted_at'] = expected_goal['deleted_at'].replace( - tzinfo=iso8601.iso8601.Utc()) + tzinfo=iso8601.UTC) uuid = self.fake_goal['uuid'] goal = objects.Goal.get_by_uuid(self.context, uuid) diff --git a/watcher/tests/objects/test_objects.py b/watcher/tests/objects/test_objects.py index 50dd62045..fd1856a2f 100644 --- a/watcher/tests/objects/test_objects.py +++ b/watcher/tests/objects/test_objects.py @@ -269,7 +269,7 @@ class _TestObject(object): self.assertEqual('updated', obj.bar) def test_base_attributes(self): - dt = datetime.datetime(1955, 11, 5, 0, 0, tzinfo=iso8601.iso8601.Utc()) + dt = datetime.datetime(1955, 11, 5, 0, 0, tzinfo=iso8601.UTC) datatime = fields.DateTimeField() obj = MyObj(self.context) obj.created_at = dt diff --git a/watcher/tests/objects/test_scoring_engine.py b/watcher/tests/objects/test_scoring_engine.py index e27fbcffd..35730b600 100644 --- a/watcher/tests/objects/test_scoring_engine.py +++ b/watcher/tests/objects/test_scoring_engine.py @@ -78,7 +78,7 @@ class TestScoringEngineObject(base.DbTestCase): scoring_engine.create() expected_scoring_engine = self.fake_scoring_engine.copy() expected_scoring_engine['created_at'] = expected_scoring_engine[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) mock_create_scoring_engine.assert_called_once_with( expected_scoring_engine) self.assertEqual(self.context, scoring_engine._context) @@ -139,9 +139,9 @@ class TestScoringEngineObject(base.DbTestCase): expected_scoring_engine = fake_deleted_scoring_engine.copy() expected_scoring_engine['created_at'] = expected_scoring_engine[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) expected_scoring_engine['deleted_at'] = expected_scoring_engine[ - 'deleted_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'deleted_at'].replace(tzinfo=iso8601.UTC) _id = self.fake_scoring_engine['id'] scoring_engine = objects.ScoringEngine.get_by_id(self.context, _id) diff --git a/watcher/tests/objects/test_service.py b/watcher/tests/objects/test_service.py index 0dcef21fb..cdfd99040 100644 --- a/watcher/tests/objects/test_service.py +++ b/watcher/tests/objects/test_service.py @@ -56,7 +56,7 @@ class TestServiceObject(base.DbTestCase): service.create() expected_service = self.fake_service.copy() expected_service['created_at'] = expected_service[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) mock_create_service.assert_called_once_with(expected_service) self.assertEqual(self.context, service._context) @@ -103,9 +103,9 @@ class TestServiceObject(base.DbTestCase): expected_service = fake_deleted_service.copy() expected_service['created_at'] = expected_service[ - 'created_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'created_at'].replace(tzinfo=iso8601.UTC) expected_service['deleted_at'] = expected_service[ - 'deleted_at'].replace(tzinfo=iso8601.iso8601.Utc()) + 'deleted_at'].replace(tzinfo=iso8601.UTC) _id = self.fake_service['id'] service = objects.Service.get(self.context, _id)