Drop direct dependency on iso8601
iso8601.iso8601.UTC has been equivalent to datetime.timezone.utc in Python 3. Because python 2 is no longer supported, we can directly use the built-in implementation. Also replace iso8601.parse_date by the common function in oslo.utils . Change-Id: I933cc5dd1fa76e320cd96cd8e9b9a7963ff70375
This commit is contained in:
@@ -17,7 +17,6 @@ import collections
|
|||||||
import datetime
|
import datetime
|
||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
@@ -243,7 +242,7 @@ class SimpleTenantUsageController(wsgi.Controller):
|
|||||||
# instance object fields and still maintain backwards compatibility
|
# instance object fields and still maintain backwards compatibility
|
||||||
# in the API.
|
# in the API.
|
||||||
if value.utcoffset() is None:
|
if value.utcoffset() is None:
|
||||||
value = value.replace(tzinfo=iso8601.UTC)
|
value = value.replace(tzinfo=datetime.timezone.utc)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def _get_datetime_range(self, req):
|
def _get_datetime_range(self, req):
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ Manage hosts in the current zone.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import collections
|
import collections
|
||||||
|
import datetime
|
||||||
import functools
|
import functools
|
||||||
import time
|
import time
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
@@ -88,7 +88,7 @@ def set_update_time_on_success(function):
|
|||||||
else:
|
else:
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
# NOTE(sbauza): Objects are UTC tz-aware by default
|
# NOTE(sbauza): Objects are UTC tz-aware by default
|
||||||
self.updated = now.replace(tzinfo=iso8601.UTC)
|
self.updated = now.replace(tzinfo=datetime.timezone.utc)
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
return decorated_function
|
return decorated_function
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import iso8601
|
import datetime
|
||||||
|
|
||||||
from oslo_log import log as logging
|
from oslo_log import log as logging
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
@@ -77,7 +78,8 @@ class MemcachedDriver(base.Driver):
|
|||||||
|
|
||||||
if updated_time_in_mc:
|
if updated_time_in_mc:
|
||||||
# Change mc time to offset-aware time
|
# Change mc time to offset-aware time
|
||||||
updated_time_in_mc = updated_time_in_mc.replace(tzinfo=iso8601.UTC)
|
updated_time_in_mc = updated_time_in_mc.replace(
|
||||||
|
tzinfo=datetime.timezone.utc)
|
||||||
# If [DEFAULT]/enable_new_services is set to be false, the
|
# If [DEFAULT]/enable_new_services is set to be false, the
|
||||||
# ``updated_time_in_db`` will be None, in this case, use
|
# ``updated_time_in_db`` will be None, in this case, use
|
||||||
# ``updated_time_in_mc`` instead.
|
# ``updated_time_in_mc`` instead.
|
||||||
|
|||||||
@@ -15,9 +15,9 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_utils.fixture import uuidsentinel
|
from oslo_utils.fixture import uuidsentinel
|
||||||
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from nova.api.openstack.compute import availability_zone as az_v21
|
from nova.api.openstack.compute import availability_zone as az_v21
|
||||||
from nova.api.openstack.compute import servers as servers_v21
|
from nova.api.openstack.compute import servers as servers_v21
|
||||||
@@ -135,7 +135,7 @@ class AvailabilityZoneApiTestV21(test.NoDBTestCase):
|
|||||||
self.assertIn('availabilityZoneInfo', resp_dict)
|
self.assertIn('availabilityZoneInfo', resp_dict)
|
||||||
zones = resp_dict['availabilityZoneInfo']
|
zones = resp_dict['availabilityZoneInfo']
|
||||||
self.assertEqual(len(zones), 3)
|
self.assertEqual(len(zones), 3)
|
||||||
timestamp = iso8601.parse_date("2012-12-26T14:45:25Z")
|
timestamp = timeutils.parse_isotime("2012-12-26T14:45:25Z")
|
||||||
expected = [
|
expected = [
|
||||||
{
|
{
|
||||||
'zoneName': 'internal',
|
'zoneName': 'internal',
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import copy
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_policy import policy as oslo_policy
|
from oslo_policy import policy as oslo_policy
|
||||||
from oslo_utils.fixture import uuidsentinel as uuids
|
from oslo_utils.fixture import uuidsentinel as uuids
|
||||||
from webob import exc
|
from webob import exc
|
||||||
@@ -383,9 +382,9 @@ class InstanceActionsTestV266(InstanceActionsTestV258):
|
|||||||
|
|
||||||
self.controller.index(req, FAKE_UUID)
|
self.controller.index(req, FAKE_UUID)
|
||||||
filters = {'changes-since': datetime.datetime(
|
filters = {'changes-since': datetime.datetime(
|
||||||
2012, 12, 5, 0, 0, tzinfo=iso8601.iso8601.UTC),
|
2012, 12, 5, 0, 0, tzinfo=datetime.timezone.utc),
|
||||||
'changes-before': datetime.datetime(
|
'changes-before': datetime.datetime(
|
||||||
2012, 12, 5, 1, 0, tzinfo=iso8601.iso8601.UTC)}
|
2012, 12, 5, 1, 0, tzinfo=datetime.timezone.utc)}
|
||||||
mock_action_get.assert_called_once_with(req.environ['nova.context'],
|
mock_action_get.assert_called_once_with(req.environ['nova.context'],
|
||||||
instance, limit=1000,
|
instance, limit=1000,
|
||||||
marker=None,
|
marker=None,
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_utils.fixture import uuidsentinel as uuids
|
from oslo_utils.fixture import uuidsentinel as uuids
|
||||||
from webob import exc
|
from webob import exc
|
||||||
|
|
||||||
@@ -396,10 +395,10 @@ class MigrationTestCaseV266(MigrationsTestCaseV259):
|
|||||||
search_opts = {'instance_uuid': uuids.instance_uuid,
|
search_opts = {'instance_uuid': uuids.instance_uuid,
|
||||||
'changes-before':
|
'changes-before':
|
||||||
datetime.datetime(2013, 10, 22, 13, 42, 3,
|
datetime.datetime(2013, 10, 22, 13, 42, 3,
|
||||||
tzinfo=iso8601.iso8601.UTC),
|
tzinfo=datetime.timezone.utc),
|
||||||
'changes-since':
|
'changes-since':
|
||||||
datetime.datetime(2013, 10, 22, 13, 42, 2,
|
datetime.datetime(2013, 10, 22, 13, 42, 2,
|
||||||
tzinfo=iso8601.iso8601.UTC)}
|
tzinfo=datetime.timezone.utc)}
|
||||||
get_migrations_sorted.assert_called_once_with(
|
get_migrations_sorted.assert_called_once_with(
|
||||||
req.environ['nova.context'], search_opts, sort_dirs=mock.ANY,
|
req.environ['nova.context'], search_opts, sort_dirs=mock.ANY,
|
||||||
sort_keys=mock.ANY, limit=1000, marker=None)
|
sort_keys=mock.ANY, limit=1000, marker=None)
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import functools
|
|||||||
from urllib import parse as urlparse
|
from urllib import parse as urlparse
|
||||||
|
|
||||||
import fixtures
|
import fixtures
|
||||||
import iso8601
|
|
||||||
from oslo_policy import policy as oslo_policy
|
from oslo_policy import policy as oslo_policy
|
||||||
from oslo_serialization import base64
|
from oslo_serialization import base64
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
@@ -1398,7 +1397,7 @@ class ServersControllerTest(_ServersControllerTest):
|
|||||||
self.assertIsNotNone(search_opts)
|
self.assertIsNotNone(search_opts)
|
||||||
self.assertIn('changes-since', search_opts)
|
self.assertIn('changes-since', search_opts)
|
||||||
changes_since = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
changes_since = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
||||||
tzinfo=iso8601.iso8601.UTC)
|
tzinfo=datetime.timezone.utc)
|
||||||
self.assertEqual(search_opts['changes-since'], changes_since)
|
self.assertEqual(search_opts['changes-since'], changes_since)
|
||||||
self.assertNotIn('deleted', search_opts)
|
self.assertNotIn('deleted', search_opts)
|
||||||
return objects.InstanceList(
|
return objects.InstanceList(
|
||||||
@@ -2475,7 +2474,7 @@ class ServersControllerTestV266(ControllerTest):
|
|||||||
self.assertIsNotNone(search_opts)
|
self.assertIsNotNone(search_opts)
|
||||||
self.assertIn('changes-before', search_opts)
|
self.assertIn('changes-before', search_opts)
|
||||||
changes_before = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
changes_before = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
||||||
tzinfo=iso8601.iso8601.UTC)
|
tzinfo=datetime.timezone.utc)
|
||||||
self.assertEqual(search_opts['changes-before'], changes_before)
|
self.assertEqual(search_opts['changes-before'], changes_before)
|
||||||
self.assertNotIn('deleted', search_opts)
|
self.assertNotIn('deleted', search_opts)
|
||||||
return objects.InstanceList(
|
return objects.InstanceList(
|
||||||
@@ -2513,10 +2512,10 @@ class ServersControllerTestV266(ControllerTest):
|
|||||||
self.assertIsNotNone(search_opts)
|
self.assertIsNotNone(search_opts)
|
||||||
self.assertIn('changes-since', search_opts)
|
self.assertIn('changes-since', search_opts)
|
||||||
changes_since = datetime.datetime(2011, 1, 23, 17, 8, 1,
|
changes_since = datetime.datetime(2011, 1, 23, 17, 8, 1,
|
||||||
tzinfo=iso8601.iso8601.UTC)
|
tzinfo=datetime.timezone.utc)
|
||||||
self.assertIn('changes-before', search_opts)
|
self.assertIn('changes-before', search_opts)
|
||||||
changes_before = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
changes_before = datetime.datetime(2011, 1, 24, 17, 8, 1,
|
||||||
tzinfo=iso8601.iso8601.UTC)
|
tzinfo=datetime.timezone.utc)
|
||||||
self.assertEqual(search_opts['changes-since'], changes_since)
|
self.assertEqual(search_opts['changes-since'], changes_since)
|
||||||
self.assertEqual(search_opts['changes-before'], changes_before)
|
self.assertEqual(search_opts['changes-before'], changes_before)
|
||||||
self.assertNotIn('deleted', search_opts)
|
self.assertNotIn('deleted', search_opts)
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ from unittest import mock
|
|||||||
|
|
||||||
import ddt
|
import ddt
|
||||||
import fixtures
|
import fixtures
|
||||||
import iso8601
|
|
||||||
import os_traits as ot
|
import os_traits as ot
|
||||||
from oslo_limit import exception as limit_exceptions
|
from oslo_limit import exception as limit_exceptions
|
||||||
from oslo_messaging import exceptions as oslo_exceptions
|
from oslo_messaging import exceptions as oslo_exceptions
|
||||||
@@ -981,7 +980,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
|
|
||||||
def _test_delete(self, delete_type, **attrs):
|
def _test_delete(self, delete_type, **attrs):
|
||||||
delete_time = datetime.datetime(
|
delete_time = datetime.datetime(
|
||||||
1955, 11, 5, 9, 30, tzinfo=iso8601.UTC)
|
1955, 11, 5, 9, 30, tzinfo=datetime.timezone.utc)
|
||||||
timeutils.set_time_override(delete_time)
|
timeutils.set_time_override(delete_time)
|
||||||
self.addCleanup(timeutils.clear_time_override)
|
self.addCleanup(timeutils.clear_time_override)
|
||||||
|
|
||||||
@@ -1351,7 +1350,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
|||||||
|
|
||||||
mock_cons.return_value = 'constraint'
|
mock_cons.return_value = 'constraint'
|
||||||
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
||||||
tzinfo=iso8601.UTC)
|
tzinfo=datetime.timezone.utc)
|
||||||
updates['deleted_at'] = delete_time
|
updates['deleted_at'] = delete_time
|
||||||
updates['deleted'] = True
|
updates['deleted'] = True
|
||||||
fake_inst = fake_instance.fake_db_instance(**updates)
|
fake_inst = fake_instance.fake_db_instance(**updates)
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import datetime
|
|||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from dateutil import parser as dateutil_parser
|
from dateutil import parser as dateutil_parser
|
||||||
import iso8601
|
|
||||||
import netaddr
|
import netaddr
|
||||||
from oslo_db import api as oslo_db_api
|
from oslo_db import api as oslo_db_api
|
||||||
from oslo_db import exception as db_exc
|
from oslo_db import exception as db_exc
|
||||||
@@ -682,8 +681,8 @@ class SqlAlchemyDbApiNoDbTestCase(test.NoDBTestCase):
|
|||||||
t2 = t1 + datetime.timedelta(seconds=10)
|
t2 = t1 + datetime.timedelta(seconds=10)
|
||||||
t3 = t2 + datetime.timedelta(hours=1)
|
t3 = t2 + datetime.timedelta(hours=1)
|
||||||
|
|
||||||
t2_utc = t2.replace(tzinfo=iso8601.UTC)
|
t2_utc = t2.replace(tzinfo=datetime.timezone.utc)
|
||||||
t3_utc = t3.replace(tzinfo=iso8601.UTC)
|
t3_utc = t3.replace(tzinfo=datetime.timezone.utc)
|
||||||
|
|
||||||
datetime_keys = ('created_at', 'deleted_at')
|
datetime_keys = ('created_at', 'deleted_at')
|
||||||
|
|
||||||
@@ -1553,7 +1552,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
dt_keys = ('created_at', 'deleted_at', 'updated_at',
|
dt_keys = ('created_at', 'deleted_at', 'updated_at',
|
||||||
'launched_at', 'terminated_at')
|
'launched_at', 'terminated_at')
|
||||||
dt = timeutils.utcnow()
|
dt = timeutils.utcnow()
|
||||||
dt_utc = dt.replace(tzinfo=iso8601.UTC)
|
dt_utc = dt.replace(tzinfo=datetime.timezone.utc)
|
||||||
for key in dt_keys:
|
for key in dt_keys:
|
||||||
values[key] = dt_utc
|
values[key] = dt_utc
|
||||||
inst = db.instance_create(self.ctxt, values)
|
inst = db.instance_create(self.ctxt, values)
|
||||||
@@ -1570,7 +1569,7 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
dt_keys = ('created_at', 'deleted_at', 'updated_at',
|
dt_keys = ('created_at', 'deleted_at', 'updated_at',
|
||||||
'launched_at', 'terminated_at')
|
'launched_at', 'terminated_at')
|
||||||
dt = timeutils.utcnow()
|
dt = timeutils.utcnow()
|
||||||
dt_utc = dt.replace(tzinfo=iso8601.UTC)
|
dt_utc = dt.replace(tzinfo=datetime.timezone.utc)
|
||||||
for key in dt_keys:
|
for key in dt_keys:
|
||||||
values[key] = dt_utc
|
values[key] = dt_utc
|
||||||
inst = db.instance_create(self.ctxt, {})
|
inst = db.instance_create(self.ctxt, {})
|
||||||
@@ -1795,13 +1794,13 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
'2013-12-05T15:03:25.000000')
|
'2013-12-05T15:03:25.000000')
|
||||||
i2 = self.create_instance_with_args(updated_at=
|
i2 = self.create_instance_with_args(updated_at=
|
||||||
'2013-12-05T15:03:26.000000')
|
'2013-12-05T15:03:26.000000')
|
||||||
changes_since = iso8601.parse_date('2013-12-05T15:03:25.000000')
|
changes_since = timeutils.parse_isotime('2013-12-05T15:03:25.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-since':
|
{'changes-since':
|
||||||
changes_since})
|
changes_since})
|
||||||
self._assertEqualListsOfInstances([i1, i2], result)
|
self._assertEqualListsOfInstances([i1, i2], result)
|
||||||
|
|
||||||
changes_since = iso8601.parse_date('2013-12-05T15:03:26.000000')
|
changes_since = timeutils.parse_isotime('2013-12-05T15:03:26.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-since':
|
{'changes-since':
|
||||||
changes_since})
|
changes_since})
|
||||||
@@ -1820,13 +1819,13 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
'2013-12-05T15:03:25.000000')
|
'2013-12-05T15:03:25.000000')
|
||||||
i2 = self.create_instance_with_args(updated_at=
|
i2 = self.create_instance_with_args(updated_at=
|
||||||
'2013-12-05T15:03:26.000000')
|
'2013-12-05T15:03:26.000000')
|
||||||
changes_before = iso8601.parse_date('2013-12-05T15:03:26.000000')
|
changes_before = timeutils.parse_isotime('2013-12-05T15:03:26.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-before':
|
{'changes-before':
|
||||||
changes_before})
|
changes_before})
|
||||||
self._assertEqualListsOfInstances([i1, i2], result)
|
self._assertEqualListsOfInstances([i1, i2], result)
|
||||||
|
|
||||||
changes_before = iso8601.parse_date('2013-12-05T15:03:25.000000')
|
changes_before = timeutils.parse_isotime('2013-12-05T15:03:25.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-before':
|
{'changes-before':
|
||||||
changes_before})
|
changes_before})
|
||||||
@@ -1847,8 +1846,8 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
'2013-12-05T15:03:26.000000')
|
'2013-12-05T15:03:26.000000')
|
||||||
i3 = self.create_instance_with_args(updated_at=
|
i3 = self.create_instance_with_args(updated_at=
|
||||||
'2013-12-05T15:03:27.000000')
|
'2013-12-05T15:03:27.000000')
|
||||||
changes_since = iso8601.parse_date('2013-12-05T15:03:25.000000')
|
changes_since = timeutils.parse_isotime('2013-12-05T15:03:25.000000')
|
||||||
changes_before = iso8601.parse_date('2013-12-05T15:03:27.000000')
|
changes_before = timeutils.parse_isotime('2013-12-05T15:03:27.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-since':
|
{'changes-since':
|
||||||
changes_since,
|
changes_since,
|
||||||
@@ -1856,8 +1855,8 @@ class InstanceTestCase(test.TestCase, ModelsObjectComparatorMixin):
|
|||||||
changes_before})
|
changes_before})
|
||||||
self._assertEqualListsOfInstances([i1, i2, i3], result)
|
self._assertEqualListsOfInstances([i1, i2, i3], result)
|
||||||
|
|
||||||
changes_since = iso8601.parse_date('2013-12-05T15:03:26.000000')
|
changes_since = timeutils.parse_isotime('2013-12-05T15:03:26.000000')
|
||||||
changes_before = iso8601.parse_date('2013-12-05T15:03:27.000000')
|
changes_before = timeutils.parse_isotime('2013-12-05T15:03:27.000000')
|
||||||
result = db.instance_get_all_by_filters(self.ctxt,
|
result = db.instance_get_all_by_filters(self.ctxt,
|
||||||
{'changes-since':
|
{'changes-since':
|
||||||
changes_since,
|
changes_since,
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ import datetime
|
|||||||
import os
|
import os
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_serialization import jsonutils
|
from oslo_serialization import jsonutils
|
||||||
from oslo_versionedobjects import exception as ovo_exc
|
from oslo_versionedobjects import exception as ovo_exc
|
||||||
|
|
||||||
@@ -380,7 +379,7 @@ class TestBoolean(TestField):
|
|||||||
class TestDateTime(TestField):
|
class TestDateTime(TestField):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
super(TestDateTime, self).setUp()
|
super(TestDateTime, self).setUp()
|
||||||
self.dt = datetime.datetime(1955, 11, 5, tzinfo=iso8601.UTC)
|
self.dt = datetime.datetime(1955, 11, 5, tzinfo=datetime.timezone.utc)
|
||||||
self.field = fields.DateTimeField()
|
self.field = fields.DateTimeField()
|
||||||
self.coerce_good_values = [(self.dt, self.dt),
|
self.coerce_good_values = [(self.dt, self.dt),
|
||||||
(utils.isotime(self.dt), self.dt)]
|
(utils.isotime(self.dt), self.dt)]
|
||||||
@@ -393,7 +392,7 @@ class TestDateTime(TestField):
|
|||||||
'1955-11-05T18:00:00Z',
|
'1955-11-05T18:00:00Z',
|
||||||
self.field.stringify(
|
self.field.stringify(
|
||||||
datetime.datetime(1955, 11, 5, 18, 0, 0,
|
datetime.datetime(1955, 11, 5, 18, 0, 0,
|
||||||
tzinfo=iso8601.UTC)))
|
tzinfo=datetime.timezone.utc)))
|
||||||
|
|
||||||
|
|
||||||
class TestDict(TestField):
|
class TestDict(TestField):
|
||||||
|
|||||||
@@ -13,7 +13,6 @@
|
|||||||
import datetime
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
import iso8601
|
|
||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from nova import objects
|
from nova import objects
|
||||||
@@ -71,9 +70,9 @@ class _TestTaskLog(object):
|
|||||||
self.context,
|
self.context,
|
||||||
fake_task_log['task_name'],
|
fake_task_log['task_name'],
|
||||||
fake_task_log['period_beginning'].replace(
|
fake_task_log['period_beginning'].replace(
|
||||||
tzinfo=iso8601.UTC),
|
tzinfo=datetime.timezone.utc),
|
||||||
fake_task_log['period_ending'].replace(
|
fake_task_log['period_ending'].replace(
|
||||||
tzinfo=iso8601.UTC),
|
tzinfo=datetime.timezone.utc),
|
||||||
fake_task_log['host'],
|
fake_task_log['host'],
|
||||||
task_items=fake_task_log['task_items'],
|
task_items=fake_task_log['task_items'],
|
||||||
message=fake_task_log['message'])
|
message=fake_task_log['message'])
|
||||||
@@ -92,9 +91,9 @@ class _TestTaskLog(object):
|
|||||||
self.context,
|
self.context,
|
||||||
fake_task_log['task_name'],
|
fake_task_log['task_name'],
|
||||||
fake_task_log['period_beginning'].replace(
|
fake_task_log['period_beginning'].replace(
|
||||||
tzinfo=iso8601.UTC),
|
tzinfo=datetime.timezone.utc),
|
||||||
fake_task_log['period_ending'].replace(
|
fake_task_log['period_ending'].replace(
|
||||||
tzinfo=iso8601.UTC),
|
tzinfo=datetime.timezone.utc),
|
||||||
fake_task_log['host'],
|
fake_task_log['host'],
|
||||||
errors=fake_task_log['errors'],
|
errors=fake_task_log['errors'],
|
||||||
message=fake_task_log['message'])
|
message=fake_task_log['message'])
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import iso8601
|
import datetime
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
from nova import servicegroup
|
from nova import servicegroup
|
||||||
@@ -72,7 +72,7 @@ class MemcachedServiceGroupTestCase(test.NoDBTestCase):
|
|||||||
service_ref = {
|
service_ref = {
|
||||||
'host': 'fake-host',
|
'host': 'fake-host',
|
||||||
'topic': 'compute',
|
'topic': 'compute',
|
||||||
'updated_at': updated_at_time.replace(tzinfo=iso8601.UTC)
|
'updated_at': updated_at_time.replace(tzinfo=datetime.timezone.utc)
|
||||||
}
|
}
|
||||||
|
|
||||||
# If no record returned from the mc, return record from DB
|
# If no record returned from the mc, return record from DB
|
||||||
@@ -84,13 +84,13 @@ class MemcachedServiceGroupTestCase(test.NoDBTestCase):
|
|||||||
self.mc_client.reset_mock()
|
self.mc_client.reset_mock()
|
||||||
retval = timeutils.utcnow()
|
retval = timeutils.utcnow()
|
||||||
self.mc_client.get.return_value = retval
|
self.mc_client.get.return_value = retval
|
||||||
self.assertEqual(retval.replace(tzinfo=iso8601.UTC),
|
self.assertEqual(retval.replace(tzinfo=datetime.timezone.utc),
|
||||||
self.servicegroup_api.get_updated_time(service_ref))
|
self.servicegroup_api.get_updated_time(service_ref))
|
||||||
self.mc_client.get.assert_called_once_with('compute:fake-host')
|
self.mc_client.get.assert_called_once_with('compute:fake-host')
|
||||||
# If the record in DB is newer than mc, return record from DB
|
# If the record in DB is newer than mc, return record from DB
|
||||||
self.mc_client.reset_mock()
|
self.mc_client.reset_mock()
|
||||||
service_ref['updated_at'] = \
|
service_ref['updated_at'] = \
|
||||||
retval.replace(tzinfo=iso8601.UTC)
|
retval.replace(tzinfo=datetime.timezone.utc)
|
||||||
self.mc_client.get.return_value = updated_at_time
|
self.mc_client.get.return_value = updated_at_time
|
||||||
self.assertEqual(service_ref['updated_at'],
|
self.assertEqual(service_ref['updated_at'],
|
||||||
self.servicegroup_api.get_updated_time(service_ref))
|
self.servicegroup_api.get_updated_time(service_ref))
|
||||||
@@ -99,6 +99,6 @@ class MemcachedServiceGroupTestCase(test.NoDBTestCase):
|
|||||||
self.mc_client.reset_mock()
|
self.mc_client.reset_mock()
|
||||||
service_ref['updated_at'] = None
|
service_ref['updated_at'] = None
|
||||||
self.mc_client.get.return_value = updated_at_time
|
self.mc_client.get.return_value = updated_at_time
|
||||||
self.assertEqual(updated_at_time.replace(tzinfo=iso8601.UTC),
|
self.assertEqual(updated_at_time.replace(tzinfo=datetime.timezone.utc),
|
||||||
self.servicegroup_api.get_updated_time(service_ref))
|
self.servicegroup_api.get_updated_time(service_ref))
|
||||||
self.mc_client.get.assert_called_once_with('compute:fake-host')
|
self.mc_client.get.assert_called_once_with('compute:fake-host')
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ PrettyTable>=0.7.1 # BSD
|
|||||||
alembic>=1.5.0 # MIT
|
alembic>=1.5.0 # MIT
|
||||||
netaddr>=0.7.18 # BSD
|
netaddr>=0.7.18 # BSD
|
||||||
paramiko>=2.7.1 # LGPLv2.1+
|
paramiko>=2.7.1 # LGPLv2.1+
|
||||||
iso8601>=0.1.11 # MIT
|
|
||||||
jsonschema>=4.0.0 # MIT
|
jsonschema>=4.0.0 # MIT
|
||||||
python-cinderclient>=4.0.1 # Apache-2.0
|
python-cinderclient>=4.0.1 # Apache-2.0
|
||||||
keystoneauth1>=3.16.0 # Apache-2.0
|
keystoneauth1>=3.16.0 # Apache-2.0
|
||||||
|
|||||||
Reference in New Issue
Block a user