From 75c04831bc0269225597a11b7abb2a1deefb918c Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Wed, 2 Dec 2015 16:15:43 +0100 Subject: [PATCH] Python 3: fix a lot of tests As of this commit, the following tests should now be working with Python 3: - cinder.tests.unit.api.contrib.test_cgsnapshots - cinder.tests.unit.api.contrib.test_scheduler_hints - cinder.tests.unit.api.contrib.test_snapshot_actions - cinder.tests.unit.api.contrib.test_snapshot_manage - cinder.tests.unit.api.contrib.test_snapshot_unmanage - cinder.tests.unit.api.contrib.test_volume_encryption_metadata - cinder.tests.unit.api.contrib.test_volume_host_attribute - cinder.tests.unit.api.contrib.test_volume_manage - cinder.tests.unit.api.contrib.test_volume_migration_status_attribute - cinder.tests.unit.api.contrib.test_volume_tenant_attribute - cinder.tests.unit.api.contrib.test_volume_unmanage - cinder.tests.unit.api.v2.test_volumes Most changes in this patch: - make sure that Request.body is set to bytes; - replace jsonutils.dumps with jsonutils.dump_as_bytes; - replace json.loads with oslo_serialization.jsonutils.loads; - replace dict.iteritems with dict.items. Partial-Implements: blueprint cinder-python3 Change-Id: Icbb96ff84b7012b58f7296eea4fbcd620e081614 --- .../unit/api/contrib/test_cgsnapshots.py | 30 +++++++++---------- .../unit/api/contrib/test_scheduler_hints.py | 6 ++-- .../unit/api/contrib/test_snapshot_actions.py | 6 ++-- .../unit/api/contrib/test_snapshot_manage.py | 2 +- .../api/contrib/test_snapshot_unmanage.py | 2 +- .../test_volume_encryption_metadata.py | 23 +++++++------- .../api/contrib/test_volume_host_attribute.py | 12 ++++---- .../unit/api/contrib/test_volume_manage.py | 2 +- .../test_volume_migration_status_attribute.py | 12 ++++---- .../contrib/test_volume_tenant_attribute.py | 12 ++++---- .../unit/api/contrib/test_volume_unmanage.py | 2 +- cinder/volume/api.py | 2 +- tests-py3.txt | 12 ++++++++ 13 files changed, 67 insertions(+), 56 deletions(-) diff --git a/cinder/tests/unit/api/contrib/test_cgsnapshots.py b/cinder/tests/unit/api/contrib/test_cgsnapshots.py index 7ba5bcb9f08..6206a3a50b3 100644 --- a/cinder/tests/unit/api/contrib/test_cgsnapshots.py +++ b/cinder/tests/unit/api/contrib/test_cgsnapshots.py @@ -17,10 +17,10 @@ Tests for cgsnapshot code. """ -import json from xml.dom import minidom import mock +from oslo_serialization import jsonutils import webob from cinder.consistencygroup import api as consistencygroupAPI @@ -56,7 +56,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.method = 'GET' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(200, res.status_int) self.assertEqual('this is a test cgsnapshot', @@ -100,7 +100,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.method = 'GET' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(404, res.status_int) self.assertEqual(404, res_dict['itemNotFound']['code']) @@ -123,7 +123,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.method = 'GET' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(200, res.status_int) self.assertEqual(cgsnapshot1.id, @@ -199,7 +199,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.headers['Content-Type'] = 'application/json' req.headers['Accept'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(200, res.status_int) self.assertEqual('this is a test cgsnapshot', @@ -315,10 +315,10 @@ class CgsnapshotsAPITestCase(test.TestCase): req = webob.Request.blank('/v2/fake/cgsnapshots') req.method = 'POST' req.headers['Content-Type'] = 'application/json' - req.body = json.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(202, res.status_int) self.assertIn('id', res_dict['cgsnapshot']) @@ -332,12 +332,12 @@ class CgsnapshotsAPITestCase(test.TestCase): def test_create_cgsnapshot_with_no_body(self): # omit body from the request req = webob.Request.blank('/v2/fake/cgsnapshots') - req.body = json.dumps(None) + req.body = jsonutils.dump_as_bytes(None) req.method = 'POST' req.headers['Content-Type'] = 'application/json' req.headers['Accept'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(400, res.status_int) self.assertEqual(400, res_dict['badRequest']['code']) @@ -358,11 +358,11 @@ class CgsnapshotsAPITestCase(test.TestCase): "CG Snapshot 1", "consistencygroup_id": consistencygroup.id}} req = webob.Request.blank('/v2/fake/cgsnapshots') - req.body = json.dumps(body) + req.body = jsonutils.dump_as_bytes(body) req.method = 'POST' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(400, res.status_int) self.assertEqual(400, res_dict['badRequest']['code']) @@ -386,9 +386,9 @@ class CgsnapshotsAPITestCase(test.TestCase): req = webob.Request.blank('/v2/fake/cgsnapshots') req.method = 'POST' req.headers['Content-Type'] = 'application/json' - req.body = json.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(404, res.status_int) self.assertEqual(404, res_dict['itemNotFound']['code']) @@ -425,7 +425,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.method = 'DELETE' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(404, res.status_int) self.assertEqual(404, res_dict['itemNotFound']['code']) @@ -446,7 +446,7 @@ class CgsnapshotsAPITestCase(test.TestCase): req.method = 'DELETE' req.headers['Content-Type'] = 'application/json' res = req.get_response(fakes.wsgi_app()) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) self.assertEqual(400, res.status_int) self.assertEqual(400, res_dict['badRequest']['code']) diff --git a/cinder/tests/unit/api/contrib/test_scheduler_hints.py b/cinder/tests/unit/api/contrib/test_scheduler_hints.py index fde7748522b..2e0e09c2512 100644 --- a/cinder/tests/unit/api/contrib/test_scheduler_hints.py +++ b/cinder/tests/unit/api/contrib/test_scheduler_hints.py @@ -57,7 +57,7 @@ class SchedulerHintsTestCase(test.TestCase): body = {'id': id, 'volume_type_id': 'cedef40a-ed67-4d10-800e-17455edce175', 'volume_id': '1', } - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(self.app) self.assertEqual(202, res.status_int) @@ -80,7 +80,7 @@ class SchedulerHintsTestCase(test.TestCase): 'volume_id': '1', 'scheduler_hints': {'a': 'b'}, } - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(self.app) self.assertEqual(202, res.status_int) @@ -94,6 +94,6 @@ class SchedulerHintsTestCase(test.TestCase): 'volume_id': '1', 'scheduler_hints': 'a', }} - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(self.app) self.assertEqual(400, res.status_int) diff --git a/cinder/tests/unit/api/contrib/test_snapshot_actions.py b/cinder/tests/unit/api/contrib/test_snapshot_actions.py index ba00c44a47e..e9350140eda 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_actions.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_actions.py @@ -49,7 +49,7 @@ class SnapshotActionsTest(test.TestCase): body = {'os-update_snapshot_status': {'status': 'available'}} req = webob.Request.blank('/v2/fake/snapshots/1/action') req.method = "POST" - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app()) @@ -62,7 +62,7 @@ class SnapshotActionsTest(test.TestCase): body = {'os-update_snapshot_status': {'status': 'in-use'}} req = webob.Request.blank('/v2/fake/snapshots/1/action') req.method = "POST" - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app()) @@ -73,7 +73,7 @@ class SnapshotActionsTest(test.TestCase): body = {'os-update_snapshot_status': {}} req = webob.Request.blank('/v2/fake/snapshots/1/action') req.method = "POST" - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) req.headers["content-type"] = "application/json" res = req.get_response(fakes.wsgi_app()) diff --git a/cinder/tests/unit/api/contrib/test_snapshot_manage.py b/cinder/tests/unit/api/contrib/test_snapshot_manage.py index 9e36c6451e2..a6ff239984d 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_manage.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_manage.py @@ -62,7 +62,7 @@ class SnapshotManageTest(test.TestCase): req.environ['cinder.context'] = context.RequestContext('admin', 'fake', True) - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(app()) return res diff --git a/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py b/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py index 4ce70f109f6..cf8729749e1 100644 --- a/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_snapshot_unmanage.py @@ -80,7 +80,7 @@ class SnapshotUnmanageTest(test.TestCase): 'fake', True) body = {'os-unmanage': ''} - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(app()) return res diff --git a/cinder/tests/unit/api/contrib/test_volume_encryption_metadata.py b/cinder/tests/unit/api/contrib/test_volume_encryption_metadata.py index fab674eb3fa..1dd1935b3e0 100644 --- a/cinder/tests/unit/api/contrib/test_volume_encryption_metadata.py +++ b/cinder/tests/unit/api/contrib/test_volume_encryption_metadata.py @@ -13,8 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. -import json - +from oslo_serialization import jsonutils import webob from cinder.api.contrib import volume_encryption_metadata @@ -81,7 +80,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): % self.volume_id) res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(200, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = { "encryption_key_id": "fake_key", @@ -98,7 +97,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(400, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = {'badRequest': {'code': 400, 'message': 'Malformed request url'}} self.assertEqual(expected, res_dict) @@ -110,7 +109,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(404, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = {'itemNotFound': {'code': 404, 'message': 'VolumeNotFound: Volume ' '%s could not be found.' @@ -123,7 +122,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(200, res.status_code) - self.assertEqual('fake_key', res.body) + self.assertEqual(b'fake_key', res.body) def test_show_control(self): req = webob.Request.blank('/v2/fake/volumes/%s/encryption/' @@ -131,7 +130,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(200, res.status_code) - self.assertEqual('front-end', res.body) + self.assertEqual(b'front-end', res.body) def test_show_provider(self): req = webob.Request.blank('/v2/fake/volumes/%s/encryption/' @@ -139,7 +138,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(200, res.status_code) - self.assertEqual('nova.volume.encryptors.base.VolumeEncryptor', + self.assertEqual(b'nova.volume.encryptors.base.VolumeEncryptor', res.body) def test_show_bad_tenant_id(self): @@ -149,7 +148,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(400, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = {'badRequest': {'code': 400, 'message': 'Malformed request url'}} self.assertEqual(expected, res_dict) @@ -161,7 +160,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(404, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = {'itemNotFound': {'code': 404, 'message': 'VolumeNotFound: Volume ' '%s could not be found.' @@ -176,7 +175,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=ctxt)) self.assertEqual(200, res.status_code) - self.assertEqual('fake_key', res.body) + self.assertEqual(b'fake_key', res.body) def test_show_volume_not_encrypted_type(self): self.stubs.Set(db.sqlalchemy.api, 'volume_type_encryption_get', @@ -203,7 +202,7 @@ class VolumeEncryptionMetadataTest(test.TestCase): res = req.get_response(fakes.wsgi_app(fake_auth_context=self.ctxt)) self.assertEqual(200, res.status_code) - res_dict = json.loads(res.body) + res_dict = jsonutils.loads(res.body) expected = { 'encryption_key_id': None diff --git a/cinder/tests/unit/api/contrib/test_volume_host_attribute.py b/cinder/tests/unit/api/contrib/test_volume_host_attribute.py index f6fe4919cf5..ae5b70732f8 100644 --- a/cinder/tests/unit/api/contrib/test_volume_host_attribute.py +++ b/cinder/tests/unit/api/contrib/test_volume_host_attribute.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import json import uuid from lxml import etree +from oslo_serialization import jsonutils from oslo_utils import timeutils import webob @@ -82,7 +82,7 @@ class VolumeHostAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertEqual('host001', vol['os-vol-host-attr:host']) def test_get_volume_unallowed(self): @@ -91,7 +91,7 @@ class VolumeHostAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertNotIn('os-vol-host-attr:host', vol) def test_list_detail_volumes_allowed(self): @@ -100,7 +100,7 @@ class VolumeHostAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertEqual('host001', vol[0]['os-vol-host-attr:host']) def test_list_detail_volumes_unallowed(self): @@ -109,7 +109,7 @@ class VolumeHostAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-host-attr:host', vol[0]) def test_list_simple_volumes_no_host(self): @@ -118,7 +118,7 @@ class VolumeHostAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-host-attr:host', vol[0]) def test_get_volume_xml(self): diff --git a/cinder/tests/unit/api/contrib/test_volume_manage.py b/cinder/tests/unit/api/contrib/test_volume_manage.py index d6de78a3e32..57c69f3ec04 100644 --- a/cinder/tests/unit/api/contrib/test_volume_manage.py +++ b/cinder/tests/unit/api/contrib/test_volume_manage.py @@ -130,7 +130,7 @@ class VolumeManageTest(test.TestCase): req.environ['cinder.context'] = context.RequestContext('admin', 'fake', True) - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(app()) return res diff --git a/cinder/tests/unit/api/contrib/test_volume_migration_status_attribute.py b/cinder/tests/unit/api/contrib/test_volume_migration_status_attribute.py index a3cc246d337..f27257f6b4c 100644 --- a/cinder/tests/unit/api/contrib/test_volume_migration_status_attribute.py +++ b/cinder/tests/unit/api/contrib/test_volume_migration_status_attribute.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import json import uuid from lxml import etree +from oslo_serialization import jsonutils from oslo_utils import timeutils import webob @@ -78,7 +78,7 @@ class VolumeMigStatusAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertEqual('migrating', vol['os-vol-mig-status-attr:migstat']) self.assertEqual('fake2', vol['os-vol-mig-status-attr:name_id']) @@ -88,7 +88,7 @@ class VolumeMigStatusAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertNotIn('os-vol-mig-status-attr:migstat', vol) self.assertNotIn('os-vol-mig-status-attr:name_id', vol) @@ -98,7 +98,7 @@ class VolumeMigStatusAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertEqual('migrating', vol[0]['os-vol-mig-status-attr:migstat']) self.assertEqual('fake2', vol[0]['os-vol-mig-status-attr:name_id']) @@ -108,7 +108,7 @@ class VolumeMigStatusAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-mig-status-attr:migstat', vol[0]) self.assertNotIn('os-vol-mig-status-attr:name_id', vol[0]) @@ -118,7 +118,7 @@ class VolumeMigStatusAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-mig-status-attr:migstat', vol[0]) self.assertNotIn('os-vol-mig-status-attr:name_id', vol[0]) diff --git a/cinder/tests/unit/api/contrib/test_volume_tenant_attribute.py b/cinder/tests/unit/api/contrib/test_volume_tenant_attribute.py index 54e2554546e..201af635ec3 100644 --- a/cinder/tests/unit/api/contrib/test_volume_tenant_attribute.py +++ b/cinder/tests/unit/api/contrib/test_volume_tenant_attribute.py @@ -12,10 +12,10 @@ # License for the specific language governing permissions and limitations # under the License. -import json import uuid from lxml import etree +from oslo_serialization import jsonutils import webob from cinder import context @@ -64,7 +64,7 @@ class VolumeTenantAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertEqual(PROJECT_ID, vol['os-vol-tenant-attr:tenant_id']) def test_get_volume_unallowed(self): @@ -73,7 +73,7 @@ class VolumeTenantAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volume'] + vol = jsonutils.loads(res.body)['volume'] self.assertNotIn('os-vol-tenant-attr:tenant_id', vol) def test_list_detail_volumes_allowed(self): @@ -82,7 +82,7 @@ class VolumeTenantAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertEqual(PROJECT_ID, vol[0]['os-vol-tenant-attr:tenant_id']) def test_list_detail_volumes_unallowed(self): @@ -91,7 +91,7 @@ class VolumeTenantAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-tenant-attr:tenant_id', vol[0]) def test_list_simple_volumes_no_tenant_id(self): @@ -100,7 +100,7 @@ class VolumeTenantAttributeTest(test.TestCase): req.method = 'GET' req.environ['cinder.context'] = ctx res = req.get_response(app()) - vol = json.loads(res.body)['volumes'] + vol = jsonutils.loads(res.body)['volumes'] self.assertNotIn('os-vol-tenant-attr:tenant_id', vol[0]) def test_get_volume_xml(self): diff --git a/cinder/tests/unit/api/contrib/test_volume_unmanage.py b/cinder/tests/unit/api/contrib/test_volume_unmanage.py index e94d8ad09f3..34403a86f96 100644 --- a/cinder/tests/unit/api/contrib/test_volume_unmanage.py +++ b/cinder/tests/unit/api/contrib/test_volume_unmanage.py @@ -127,7 +127,7 @@ class VolumeUnmanageTest(test.TestCase): 'fake', True) body = {'os-unmanage': ''} - req.body = jsonutils.dumps(body) + req.body = jsonutils.dump_as_bytes(body) res = req.get_response(app()) return res diff --git a/cinder/volume/api.py b/cinder/volume/api.py index ac01271a3ea..f89ed4aae64 100644 --- a/cinder/volume/api.py +++ b/cinder/volume/api.py @@ -1712,7 +1712,7 @@ class API(base.Base): def check_volume_filters(self, filters): booleans = self.db.get_booleans_for_table('volume') - for k, v in filters.iteritems(): + for k, v in filters.items(): try: if k in booleans: filters[k] = bool(v) diff --git a/tests-py3.txt b/tests-py3.txt index 3b29d79175d..9874e0efa9d 100644 --- a/tests-py3.txt +++ b/tests-py3.txt @@ -1,21 +1,33 @@ cinder.tests.unit.api.contrib.test_admin_actions cinder.tests.unit.api.contrib.test_availability_zones cinder.tests.unit.api.contrib.test_capabilities +cinder.tests.unit.api.contrib.test_cgsnapshots cinder.tests.unit.api.contrib.test_extended_snapshot_attributes cinder.tests.unit.api.contrib.test_hosts cinder.tests.unit.api.contrib.test_qos_specs_manage cinder.tests.unit.api.contrib.test_quotas cinder.tests.unit.api.contrib.test_quotas_classes +cinder.tests.unit.api.contrib.test_scheduler_hints cinder.tests.unit.api.contrib.test_scheduler_stats cinder.tests.unit.api.contrib.test_services +cinder.tests.unit.api.contrib.test_snapshot_actions +cinder.tests.unit.api.contrib.test_snapshot_manage +cinder.tests.unit.api.contrib.test_snapshot_unmanage cinder.tests.unit.api.contrib.test_types_extra_specs cinder.tests.unit.api.contrib.test_types_manage cinder.tests.unit.api.contrib.test_used_limits +cinder.tests.unit.api.contrib.test_volume_encryption_metadata +cinder.tests.unit.api.contrib.test_volume_host_attribute +cinder.tests.unit.api.contrib.test_volume_manage +cinder.tests.unit.api.contrib.test_volume_unmanage +cinder.tests.unit.api.contrib.test_volume_migration_status_attribute +cinder.tests.unit.api.contrib.test_volume_tenant_attribute cinder.tests.unit.api.openstack.test_wsgi cinder.tests.unit.api.test_common cinder.tests.unit.api.test_extensions cinder.tests.unit.api.test_versions cinder.tests.unit.api.test_xmlutil +cinder.tests.unit.api.v2.test_volumes cinder.tests.unit.image.test_cache cinder.tests.unit.image.test_glance cinder.tests.unit.keymgr.test_barbican