Use newer location for iso8601 UTC
Newer versions have moved from iso8601.iso8601.Utc() to just iso8601.UTC, causing tests to fail under py35. Change-Id: I9c0bb9f28c2abe3d7c33c4cff4fa1e968aae52ce Closes-bug: #1715486
This commit is contained in:
parent
4d5f502e84
commit
2f9ca1b4de
|
@ -39,7 +39,7 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import datetime
|
||||
from iso8601 import iso8601
|
||||
import iso8601
|
||||
import sys
|
||||
|
||||
from oslo_config import cfg
|
||||
|
@ -81,8 +81,8 @@ def _time_error(LOG, begin, end):
|
|||
if CONF.end_time:
|
||||
end = datetime.datetime.strptime(CONF.end_time,
|
||||
"%Y-%m-%d %H:%M:%S")
|
||||
begin = begin.replace(tzinfo=iso8601.Utc())
|
||||
end = end.replace(tzinfo=iso8601.Utc())
|
||||
begin = begin.replace(tzinfo=iso8601.UTC)
|
||||
end = end.replace(tzinfo=iso8601.UTC)
|
||||
if not end > begin:
|
||||
msg = _("The end time (%(end)s) must be after the start "
|
||||
"time (%(start)s).") % {'start': begin,
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
import datetime
|
||||
|
||||
from iso8601 import iso8601
|
||||
import iso8601
|
||||
from oslo_utils import timeutils
|
||||
import webob.exc
|
||||
|
||||
|
@ -65,7 +65,7 @@ LIST_RESPONSE = [{'service-status': 'available', 'service': 'cinder-volume',
|
|||
|
||||
|
||||
def stub_utcnow(with_timezone=False):
|
||||
tzinfo = iso8601.Utc() if with_timezone else None
|
||||
tzinfo = iso8601.UTC if with_timezone else None
|
||||
return datetime.datetime(2013, 7, 3, 0, 0, 2, tzinfo=tzinfo)
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import datetime
|
||||
|
||||
import ddt
|
||||
from iso8601 import iso8601
|
||||
import iso8601
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
from six.moves import http_client
|
||||
|
@ -179,7 +179,7 @@ def fake_policy_enforce(context, action, target):
|
|||
|
||||
|
||||
def fake_utcnow(with_timezone=False):
|
||||
tzinfo = iso8601.Utc() if with_timezone else None
|
||||
tzinfo = iso8601.UTC if with_timezone else None
|
||||
return datetime.datetime(2012, 10, 29, 13, 42, 11, tzinfo=tzinfo)
|
||||
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ def create_fake_volume(id, **kwargs):
|
|||
'display_name': DEFAULT_VOL_NAME,
|
||||
'display_description': DEFAULT_VOL_DESCRIPTION,
|
||||
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'volume_type_id': '3e196c20-3c06-11e2-81c1-0800200c9a66',
|
||||
|
@ -63,7 +63,7 @@ def create_fake_volume(id, **kwargs):
|
|||
{'key': 'readonly', 'value': 'False'}],
|
||||
'bootable': False,
|
||||
'launched_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'volume_type': fake_volume.fake_db_volume_type(name=DEFAULT_VOL_TYPE),
|
||||
'replication_status': 'disabled',
|
||||
'replication_extended_status': None,
|
||||
|
|
|
@ -185,9 +185,9 @@ class VolumeApiTest(test.TestCase):
|
|||
'bootable': 'false',
|
||||
'consistencygroup_id': consistencygroup_id,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.iso8601.Utc()),
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.UTC),
|
||||
'updated_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.iso8601.Utc()),
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.UTC),
|
||||
'description': description,
|
||||
'id': v2_fakes.DEFAULT_VOL_ID,
|
||||
'links':
|
||||
|
@ -753,12 +753,12 @@ class VolumeApiTest(test.TestCase):
|
|||
'host_name': None,
|
||||
'device': '/',
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
}],
|
||||
metadata={'key': 'value', 'readonly': 'True'},
|
||||
with_migration_status=True)
|
||||
expected['volume']['updated_at'] = volume_tmp['updated_at'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
self.assertEqual(expected, res_dict)
|
||||
self.assertEqual(2, len(self.notifier.notifications))
|
||||
self.assertTrue(mock_validate.called)
|
||||
|
@ -894,12 +894,12 @@ class VolumeApiTest(test.TestCase):
|
|||
'id': fake.VOLUME_ID,
|
||||
'volume_id': v2_fakes.DEFAULT_VOL_ID,
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
}],
|
||||
metadata={'key': 'value', 'readonly': 'True'},
|
||||
with_migration_status=True)
|
||||
exp_vol['volume']['updated_at'] = volume_tmp['updated_at'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
expected = {'volumes': [exp_vol['volume']]}
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
|
@ -1356,12 +1356,12 @@ class VolumeApiTest(test.TestCase):
|
|||
'host_name': None,
|
||||
'device': '/',
|
||||
'attached_at': attach_tmp['attach_time'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
}],
|
||||
metadata={'key': 'value', 'readonly': 'True'},
|
||||
with_migration_status=True)
|
||||
expected['volume']['updated_at'] = volume_tmp['updated_at'].replace(
|
||||
tzinfo=iso8601.iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
self.assertEqual(expected, res_dict)
|
||||
|
||||
def test_volume_show_with_encrypted_volume(self):
|
||||
|
|
|
@ -36,11 +36,11 @@ def fake_message(id, **kwargs):
|
|||
'message_level': "ERROR",
|
||||
'request_id': FAKE_UUID,
|
||||
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'expires_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
}
|
||||
|
||||
message.update(kwargs)
|
||||
|
@ -66,9 +66,9 @@ def create_volume(id, **kwargs):
|
|||
'display_name': DEFAULT_VOL_NAME,
|
||||
'display_description': DEFAULT_VOL_DESCRIPTION,
|
||||
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'snapshot_id': None,
|
||||
'source_volid': None,
|
||||
'volume_type_id': '3e196c20-3c06-11e2-81c1-0800200c9a66',
|
||||
|
@ -77,7 +77,7 @@ def create_volume(id, **kwargs):
|
|||
{'key': 'readonly', 'value': 'False'}],
|
||||
'bootable': False,
|
||||
'launched_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'volume_type': fake_volume.fake_db_volume_type(name=DEFAULT_VOL_TYPE),
|
||||
'replication_status': 'disabled',
|
||||
'replication_extended_status': None,
|
||||
|
|
|
@ -28,11 +28,11 @@ def stub_message(id, **kwargs):
|
|||
'message_level': "ERROR",
|
||||
'request_id': FAKE_UUID,
|
||||
'updated_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'created_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
'expires_at': datetime.datetime(1900, 1, 1, 1, 1, 1,
|
||||
tzinfo=iso8601.iso8601.Utc()),
|
||||
tzinfo=iso8601.UTC),
|
||||
}
|
||||
|
||||
message.update(kwargs)
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
import datetime
|
||||
|
||||
import ddt
|
||||
from iso8601 import iso8601
|
||||
import iso8601
|
||||
import mock
|
||||
from oslo_utils import versionutils
|
||||
|
||||
|
@ -92,7 +92,7 @@ class FakeRequest(object):
|
|||
|
||||
|
||||
def fake_utcnow(with_timezone=False):
|
||||
tzinfo = iso8601.Utc() if with_timezone else None
|
||||
tzinfo = iso8601.UTC if with_timezone else None
|
||||
return datetime.datetime(2016, 6, 1, 2, 46, 30, tzinfo=tzinfo)
|
||||
|
||||
|
||||
|
|
|
@ -307,9 +307,9 @@ class VolumeApiTest(test.TestCase):
|
|||
'consistencygroup_id': consistencygroup_id,
|
||||
'group_id': group_id,
|
||||
'created_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.iso8601.Utc()),
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.UTC),
|
||||
'updated_at': datetime.datetime(
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.iso8601.Utc()),
|
||||
1900, 1, 1, 1, 1, 1, tzinfo=iso8601.UTC),
|
||||
'description': description,
|
||||
'id': v2_fakes.DEFAULT_VOL_ID,
|
||||
'links':
|
||||
|
@ -579,7 +579,7 @@ class VolumeApiTest(test.TestCase):
|
|||
fake_volume = self._fake_create_volume()
|
||||
fake_volume['attach_status'] = fields.VolumeAttachStatus.ATTACHING
|
||||
att_time = datetime.datetime(2017, 8, 31, 21, 55, 7,
|
||||
tzinfo=iso8601.iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
a1 = {
|
||||
'id': fake.UUID1,
|
||||
'volume_id': fake.UUID2,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# under the License.
|
||||
|
||||
import datetime
|
||||
from iso8601 import iso8601
|
||||
import iso8601
|
||||
import sys
|
||||
import time
|
||||
|
||||
|
@ -1614,15 +1614,15 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
CONF.set_override('send_actions', True)
|
||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.Utc())
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.Utc())
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.UTC)
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.UTC)
|
||||
ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
get_admin_context.return_value = ctxt
|
||||
last_completed_audit_period.return_value = (begin, end)
|
||||
volume1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||
created_at=volume1_created,
|
||||
deleted_at=volume1_deleted)
|
||||
|
@ -1680,15 +1680,15 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
CONF.set_override('send_actions', True)
|
||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.Utc())
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.Utc())
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.UTC)
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.UTC)
|
||||
ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
get_admin_context.return_value = ctxt
|
||||
last_completed_audit_period.return_value = (begin, end)
|
||||
volume1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||
created_at=volume1_created,
|
||||
deleted_at=volume1_deleted)
|
||||
|
@ -1759,15 +1759,15 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
CONF.set_override('send_actions', True)
|
||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.Utc())
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.Utc())
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.UTC)
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.UTC)
|
||||
ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
get_admin_context.return_value = ctxt
|
||||
last_completed_audit_period.return_value = (begin, end)
|
||||
snapshot1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
snapshot1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
snapshot1 = mock.MagicMock(id=fake.VOLUME_ID,
|
||||
project_id=fake.PROJECT_ID,
|
||||
created_at=snapshot1_created,
|
||||
|
@ -1832,15 +1832,15 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
CONF.set_override('send_actions', True)
|
||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.Utc())
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.Utc())
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.UTC)
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.UTC)
|
||||
ctxt = context.RequestContext('fake-user', 'fake-project')
|
||||
get_admin_context.return_value = ctxt
|
||||
last_completed_audit_period.return_value = (begin, end)
|
||||
backup1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
backup1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
backup1 = mock.MagicMock(id=fake.BACKUP_ID,
|
||||
project_id=fake.PROJECT_ID,
|
||||
created_at=backup1_created,
|
||||
|
@ -1903,16 +1903,16 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
CONF.set_override('send_actions', True)
|
||||
CONF.set_override('start_time', '2014-01-01 01:00:00')
|
||||
CONF.set_override('end_time', '2014-02-02 02:00:00')
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.Utc())
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.Utc())
|
||||
begin = datetime.datetime(2014, 1, 1, 1, 0, tzinfo=iso8601.UTC)
|
||||
end = datetime.datetime(2014, 2, 2, 2, 0, tzinfo=iso8601.UTC)
|
||||
ctxt = context.RequestContext(fake.USER_ID, fake.PROJECT_ID)
|
||||
get_admin_context.return_value = ctxt
|
||||
last_completed_audit_period.return_value = (begin, end)
|
||||
|
||||
volume1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
volume1 = mock.MagicMock(id=fake.VOLUME_ID, project_id=fake.PROJECT_ID,
|
||||
created_at=volume1_created,
|
||||
deleted_at=volume1_deleted)
|
||||
|
@ -1931,9 +1931,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
}
|
||||
|
||||
snapshot1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
snapshot1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
snapshot1 = mock.MagicMock(id=fake.VOLUME_ID,
|
||||
project_id=fake.PROJECT_ID,
|
||||
created_at=snapshot1_created,
|
||||
|
@ -1949,9 +1949,9 @@ class TestCinderVolumeUsageAuditCmd(test.TestCase):
|
|||
}
|
||||
|
||||
backup1_created = datetime.datetime(2014, 1, 1, 2, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
backup1_deleted = datetime.datetime(2014, 1, 1, 3, 0,
|
||||
tzinfo=iso8601.Utc())
|
||||
tzinfo=iso8601.UTC)
|
||||
backup1 = mock.MagicMock(id=fake.BACKUP_ID,
|
||||
project_id=fake.PROJECT_ID,
|
||||
created_at=backup1_created,
|
||||
|
|
Loading…
Reference in New Issue