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: I10b84a9cc7f0cc8ea213a377e4c4f16168b6e45b Closes-Bug: #1713354
This commit is contained in:
parent
a21cac214c
commit
3d86ae664a
|
@ -242,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.iso8601.Utc())
|
value = value.replace(tzinfo=iso8601.UTC)
|
||||||
return value
|
return value
|
||||||
|
|
||||||
def _get_datetime_range(self, req):
|
def _get_datetime_range(self, req):
|
||||||
|
|
|
@ -94,7 +94,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.iso8601.Utc())
|
self.updated = now.replace(tzinfo=iso8601.UTC)
|
||||||
return return_value
|
return return_value
|
||||||
|
|
||||||
return decorated_function
|
return decorated_function
|
||||||
|
|
|
@ -77,7 +77,7 @@ 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 = \
|
||||||
updated_time_in_mc.replace(tzinfo=iso8601.iso8601.Utc())
|
updated_time_in_mc.replace(tzinfo=iso8601.UTC)
|
||||||
if updated_time_in_db <= updated_time_in_mc:
|
if updated_time_in_db <= updated_time_in_mc:
|
||||||
return updated_time_in_mc
|
return updated_time_in_mc
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ import nova.utils
|
||||||
CONF = cfg.CONF
|
CONF = cfg.CONF
|
||||||
FAKE_NETWORK_PROJECT_ID = '6133f8b603924f45bc0c9e21f6df12fa'
|
FAKE_NETWORK_PROJECT_ID = '6133f8b603924f45bc0c9e21f6df12fa'
|
||||||
|
|
||||||
UTC = iso8601.iso8601.Utc()
|
UTC = iso8601.UTC
|
||||||
FAKE_NETWORKS = [
|
FAKE_NETWORKS = [
|
||||||
{
|
{
|
||||||
'bridge': 'br100', 'vpn_public_port': 1000,
|
'bridge': 'br100', 'vpn_public_port': 1000,
|
||||||
|
|
|
@ -1180,7 +1180,7 @@ class ServicesCellsTestV21(test.TestCase):
|
||||||
def test_services_detail(self):
|
def test_services_detail(self):
|
||||||
req = FakeRequest()
|
req = FakeRequest()
|
||||||
res_dict = self.controller.index(req)
|
res_dict = self.controller.index(req)
|
||||||
utc = iso8601.iso8601.Utc()
|
utc = iso8601.UTC
|
||||||
response = {'services': [
|
response = {'services': [
|
||||||
{'id': 'cell1@1',
|
{'id': 'cell1@1',
|
||||||
'binary': 'nova-scheduler',
|
'binary': 'nova-scheduler',
|
||||||
|
|
|
@ -891,7 +891,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
'cores': -inst.flavor.vcpus,
|
'cores': -inst.flavor.vcpus,
|
||||||
'ram': -inst.flavor.memory_mb}
|
'ram': -inst.flavor.memory_mb}
|
||||||
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
||||||
tzinfo=iso8601.iso8601.Utc())
|
tzinfo=iso8601.UTC)
|
||||||
self.useFixture(utils_fixture.TimeFixture(delete_time))
|
self.useFixture(utils_fixture.TimeFixture(delete_time))
|
||||||
task_state = (delete_type == 'soft_delete' and
|
task_state = (delete_type == 'soft_delete' and
|
||||||
task_states.SOFT_DELETING or task_states.DELETING)
|
task_states.SOFT_DELETING or task_states.DELETING)
|
||||||
|
@ -1096,7 +1096,7 @@ class _ComputeAPIUnitTestMixIn(object):
|
||||||
inst, 'delete.start')
|
inst, 'delete.start')
|
||||||
db.constraint(host=mox.IgnoreArg()).AndReturn('constraint')
|
db.constraint(host=mox.IgnoreArg()).AndReturn('constraint')
|
||||||
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
delete_time = datetime.datetime(1955, 11, 5, 9, 30,
|
||||||
tzinfo=iso8601.iso8601.Utc())
|
tzinfo=iso8601.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)
|
||||||
|
|
|
@ -1052,8 +1052,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.iso8601.Utc())
|
t2_utc = t2.replace(tzinfo=iso8601.UTC)
|
||||||
t3_utc = t3.replace(tzinfo=iso8601.iso8601.Utc())
|
t3_utc = t3.replace(tzinfo=iso8601.UTC)
|
||||||
|
|
||||||
datetime_keys = ('created_at', 'deleted_at')
|
datetime_keys = ('created_at', 'deleted_at')
|
||||||
|
|
||||||
|
@ -2374,7 +2374,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.iso8601.Utc())
|
dt_utc = dt.replace(tzinfo=iso8601.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)
|
||||||
|
@ -2391,7 +2391,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.iso8601.Utc())
|
dt_utc = dt.replace(tzinfo=iso8601.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, {})
|
||||||
|
|
|
@ -69,7 +69,7 @@ class _TestBandwidthUsage(test.TestCase):
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _time_now_and_start_period():
|
def _time_now_and_start_period():
|
||||||
now = timeutils.utcnow().replace(tzinfo=iso8601.iso8601.Utc(),
|
now = timeutils.utcnow().replace(tzinfo=iso8601.UTC,
|
||||||
microsecond=0)
|
microsecond=0)
|
||||||
start_period = now - datetime.timedelta(seconds=10)
|
start_period = now - datetime.timedelta(seconds=10)
|
||||||
return now, start_period
|
return now, start_period
|
||||||
|
|
|
@ -400,7 +400,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.iso8601.Utc())
|
self.dt = datetime.datetime(1955, 11, 5, tzinfo=iso8601.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)]
|
||||||
|
@ -413,7 +413,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.iso8601.Utc())))
|
tzinfo=iso8601.UTC)))
|
||||||
|
|
||||||
|
|
||||||
class TestDict(TestField):
|
class TestDict(TestField):
|
||||||
|
|
|
@ -213,7 +213,7 @@ class _TestFixedIPObject(object):
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
now_tz = timeutils.parse_isotime(
|
now_tz = timeutils.parse_isotime(
|
||||||
utils.isotime(now)).replace(
|
utils.isotime(now)).replace(
|
||||||
tzinfo=iso8601.iso8601.Utc())
|
tzinfo=iso8601.UTC)
|
||||||
disassociate.return_value = 123
|
disassociate.return_value = 123
|
||||||
result = fixed_ip.FixedIP.disassociate_all_by_timeout(self.context,
|
result = fixed_ip.FixedIP.disassociate_all_by_timeout(self.context,
|
||||||
'host', now)
|
'host', now)
|
||||||
|
|
|
@ -71,9 +71,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.iso8601.Utc()),
|
tzinfo=iso8601.UTC),
|
||||||
fake_task_log['period_ending'].replace(
|
fake_task_log['period_ending'].replace(
|
||||||
tzinfo=iso8601.iso8601.Utc()),
|
tzinfo=iso8601.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 +92,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.iso8601.Utc()),
|
tzinfo=iso8601.UTC),
|
||||||
fake_task_log['period_ending'].replace(
|
fake_task_log['period_ending'].replace(
|
||||||
tzinfo=iso8601.iso8601.Utc()),
|
tzinfo=iso8601.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'])
|
||||||
|
|
|
@ -71,7 +71,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.iso8601.Utc())
|
'updated_at': updated_at_time.replace(tzinfo=iso8601.UTC)
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mc_client.get.return_value = None
|
self.mc_client.get.return_value = None
|
||||||
|
@ -81,12 +81,12 @@ 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.iso8601.Utc()),
|
self.assertEqual(retval.replace(tzinfo=iso8601.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')
|
||||||
self.mc_client.reset_mock()
|
self.mc_client.reset_mock()
|
||||||
service_ref['updated_at'] = \
|
service_ref['updated_at'] = \
|
||||||
retval.replace(tzinfo=iso8601.iso8601.Utc())
|
retval.replace(tzinfo=iso8601.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))
|
||||||
|
|
Loading…
Reference in New Issue