From e81bbc72b7985fce4c4d903ffe2a9a0a61c8d823 Mon Sep 17 00:00:00 2001 From: "wu.shiming" Date: Tue, 12 Jan 2021 17:18:50 +0800 Subject: [PATCH] remove unicode from code Change-Id: I2e6e9c3b3d934e1ba60b07d239e970137c32a48f --- api-ref/source/conf.py | 8 +- blazar/api/v2/controllers/extensions/host.py | 8 +- blazar/api/v2/controllers/extensions/lease.py | 22 ++-- .../versions/e069c014356d_add_floatingip.py | 2 +- blazar/plugins/floatingips/__init__.py | 2 +- blazar/plugins/instances/__init__.py | 2 +- blazar/plugins/oshosts/__init__.py | 2 +- blazar/tests/api/test_context.py | 42 ++++---- blazar/tests/api/v1/leases/test_v1_0.py | 28 ++--- blazar/tests/api/v1/oshosts/test_v1_0.py | 32 +++--- blazar/tests/api/v2/test_hosts.py | 96 ++++++++--------- blazar/tests/api/v2/test_leases.py | 90 ++++++++-------- blazar/tests/fake_lease.py | 18 ++-- blazar/tests/manager/test_service.py | 78 +++++++------- .../floatingips/test_floatingip_plugin.py | 56 +++++----- .../oshosts/test_physical_host_plugin.py | 100 +++++++++--------- blazar/tests/test_context.py | 2 +- doc/source/conf.py | 14 +-- releasenotes/source/conf.py | 14 +-- 19 files changed, 308 insertions(+), 308 deletions(-) diff --git a/api-ref/source/conf.py b/api-ref/source/conf.py index 3761696a..f4a69d16 100644 --- a/api-ref/source/conf.py +++ b/api-ref/source/conf.py @@ -57,8 +57,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -copyright = u'2017-present, OpenStack Foundation' -author = u'OpenStack Foundation' +copyright = '2017-present, OpenStack Foundation' +author = 'OpenStack Foundation' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -110,6 +110,6 @@ htmlhelp_basename = 'blazardoc' # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'ReservationAPIReference.tex', u'OpenStack Reservation API Reference Documentation', - u'OpenStack Foundation', 'manual'), + (master_doc, 'ReservationAPIReference.tex', 'OpenStack Reservation API Reference Documentation', + 'OpenStack Foundation', 'manual'), ] diff --git a/blazar/api/v2/controllers/extensions/host.py b/blazar/api/v2/controllers/extensions/host.py index d54901e6..0ffe396c 100644 --- a/blazar/api/v2/controllers/extensions/host.py +++ b/blazar/api/v2/controllers/extensions/host.py @@ -85,9 +85,9 @@ class Host(base._Base): @classmethod def sample(cls): - return cls(id=u'1', - hypervisor_hostname=u'host01', - hypervisor_type=u'QEMU', + return cls(id='1', + hypervisor_hostname='host01', + hypervisor_type='QEMU', vcpus=1, hypervisor_version=1000000, memory_mb=8192, @@ -95,7 +95,7 @@ class Host(base._Base): cpu_info="{\"vendor\": \"Intel\", \"model\": \"qemu32\", " "\"arch\": \"x86_64\", \"features\": []," " \"topology\": {\"cores\": 1}}", - extra_capas={u'vgpus': 2, u'fruits': u'bananas'}, + extra_capas={'vgpus': 2, 'fruits': 'bananas'}, ) diff --git a/blazar/api/v2/controllers/extensions/lease.py b/blazar/api/v2/controllers/extensions/lease.py index a74998e4..6af8b890 100644 --- a/blazar/api/v2/controllers/extensions/lease.py +++ b/blazar/api/v2/controllers/extensions/lease.py @@ -64,18 +64,18 @@ class Lease(base._Base): @classmethod def sample(cls): - return cls(id=u'2bb8720a-0873-4d97-babf-0d906851a1eb', - name=u'lease_test', - start_date=u'2014-01-01 01:23', - end_date=u'2014-02-01 13:37', - user_id=u'efd8780712d24b389c705f5c2ac427ff', - project_id=u'bd9431c18d694ad3803a8d4a6b89fd36', - trust_id=u'35b17138b3644e6aa1318f3099c5be68', - reservations=[{u'resource_id': u'1234', - u'resource_type': u'physical:host'}], + return cls(id='2bb8720a-0873-4d97-babf-0d906851a1eb', + name='lease_test', + start_date='2014-01-01 01:23', + end_date='2014-02-01 13:37', + user_id='efd8780712d24b389c705f5c2ac427ff', + project_id='bd9431c18d694ad3803a8d4a6b89fd36', + trust_id='35b17138b3644e6aa1318f3099c5be68', + reservations=[{'resource_id': '1234', + 'resource_type': 'physical:host'}], events=[], - before_end_date=u'2014-02-01 10:37', - status=u'ACTIVE', + before_end_date='2014-02-01 10:37', + status='ACTIVE', ) diff --git a/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py b/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py index 90388712..5f6b88db 100644 --- a/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py +++ b/blazar/db/migration/alembic_migrations/versions/e069c014356d_add_floatingip.py @@ -42,7 +42,7 @@ def upgrade(): sa.Column('floating_ip_address', sa.String(length=255), nullable=False), sa.Column('reservable', sa.Boolean(), - server_default=sa.text(u'true'), nullable=False), + server_default=sa.text('true'), nullable=False), sa.PrimaryKeyConstraint('id'), sa.UniqueConstraint('subnet_id', 'floating_ip_address')) # ### end Alembic commands ### diff --git a/blazar/plugins/floatingips/__init__.py b/blazar/plugins/floatingips/__init__.py index 4539689d..d00ee57e 100644 --- a/blazar/plugins/floatingips/__init__.py +++ b/blazar/plugins/floatingips/__init__.py @@ -12,4 +12,4 @@ # License for the specific language governing permissions and limitations # under the License. -RESOURCE_TYPE = u'virtual:floatingip' +RESOURCE_TYPE = 'virtual:floatingip' diff --git a/blazar/plugins/instances/__init__.py b/blazar/plugins/instances/__init__.py index 08ed6b0e..7e04451b 100644 --- a/blazar/plugins/instances/__init__.py +++ b/blazar/plugins/instances/__init__.py @@ -12,4 +12,4 @@ # License for the specific language governing permissions and limitations # under the License. -RESOURCE_TYPE = u'virtual:instance' +RESOURCE_TYPE = 'virtual:instance' diff --git a/blazar/plugins/oshosts/__init__.py b/blazar/plugins/oshosts/__init__.py index 375dd1f9..b349d2d4 100644 --- a/blazar/plugins/oshosts/__init__.py +++ b/blazar/plugins/oshosts/__init__.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -RESOURCE_TYPE = u'physical:host' +RESOURCE_TYPE = 'physical:host' diff --git a/blazar/tests/api/test_context.py b/blazar/tests/api/test_context.py index 1f9a8206..c2c02046 100644 --- a/blazar/tests/api/test_context.py +++ b/blazar/tests/api/test_context.py @@ -29,12 +29,12 @@ class ContextTestCase(tests.TestCase): def setUp(self): super(ContextTestCase, self).setUp() - self.fake_headers = {u'X-User-Id': uuidsentinel.user_id, - u'X-Project-Id': uuidsentinel.project_id, - u'X-Auth-Token': u'111-111-111', - u'X-User-Name': u'user_name', - u'X-Project-Name': u'project_name', - u'X-Roles': u'user_name0, user_name1'} + self.fake_headers = {'X-User-Id': uuidsentinel.user_id, + 'X-Project-Id': uuidsentinel.project_id, + 'X-Auth-Token': '111-111-111', + 'X-User-Name': 'user_name', + 'X-Project-Name': 'project_name', + 'X-Roles': 'user_name0, user_name1'} self.context = self.patch(context, 'BlazarContext') self.catalog = jsonutils.dump_as_bytes({'nova': 'catalog'}) @@ -46,7 +46,7 @@ class ContextTestCase(tests.TestCase): def test_ctx_from_headers_wrong_format(self): catalog = ['etc'] - self.fake_headers[u'X-Service-Catalog'] = catalog + self.fake_headers['X-Service-Catalog'] = catalog self.assertRaises( exceptions.WrongFormat, api_context.ctx_from_headers, @@ -56,7 +56,7 @@ class ContextTestCase(tests.TestCase): class ContextTestCaseV1(ContextTestCase): def test_ctx_from_headers(self): - self.fake_headers[u'X-Service-Catalog'] = self.catalog + self.fake_headers['X-Service-Catalog'] = self.catalog environ_base = { 'openstack.request_id': 'req-' + uuidsentinel.reqid, 'openstack.global_request_id': 'req-' + uuidsentinel.globalreqid} @@ -68,13 +68,13 @@ class ContextTestCaseV1(ContextTestCase): self.context.assert_called_once_with( user_id=uuidsentinel.user_id, - roles=[u'user_name0', - u'user_name1'], - project_name=u'project_name', - auth_token=u'111-111-111', - service_catalog={u'nova': u'catalog'}, + roles=['user_name0', + 'user_name1'], + project_name='project_name', + auth_token='111-111-111', + service_catalog={'nova': 'catalog'}, project_id=uuidsentinel.project_id, - user_name=u'user_name', + user_name='user_name', request_id='req-' + uuidsentinel.reqid, global_request_id='req-' + uuidsentinel.globalreqid) @@ -82,17 +82,17 @@ class ContextTestCaseV1(ContextTestCase): class ContextTestCaseV2(ContextTestCase): def test_ctx_from_headers(self): - self.fake_headers[u'X-Service-Catalog'] = self.catalog + self.fake_headers['X-Service-Catalog'] = self.catalog req = webob.Request.blank('/v2/leases') req.headers = self.fake_headers api_context.ctx_from_headers(req.headers) self.context.assert_called_once_with( user_id=uuidsentinel.user_id, - roles=[u'user_name0', - u'user_name1'], - project_name=u'project_name', - auth_token=u'111-111-111', - service_catalog={u'nova': u'catalog'}, + roles=['user_name0', + 'user_name1'], + project_name='project_name', + auth_token='111-111-111', + service_catalog={'nova': 'catalog'}, project_id=uuidsentinel.project_id, - user_name=u'user_name') + user_name='user_name') diff --git a/blazar/tests/api/v1/leases/test_v1_0.py b/blazar/tests/api/v1/leases/test_v1_0.py index aea5e035..bd74a420 100644 --- a/blazar/tests/api/v1/leases/test_v1_0.py +++ b/blazar/tests/api/v1/leases/test_v1_0.py @@ -45,23 +45,23 @@ def make_app(): def fake_lease(**kw): return { - u'id': kw.get('id', u'2bb8720a-0873-4d97-babf-0d906851a1eb'), - u'name': kw.get('name', u'lease_test'), - u'start_date': kw.get('start_date', u'2014-01-01 01:23'), - u'end_date': kw.get('end_date', u'2014-02-01 13:37'), - u'trust_id': kw.get('trust_id', - u'35b17138b3644e6aa1318f3099c5be68'), - u'user_id': kw.get('user_id', u'efd8780712d24b389c705f5c2ac427ff'), - u'project_id': kw.get('project_id', - u'bd9431c18d694ad3803a8d4a6b89fd36'), - u'reservations': kw.get('reservations', [ + 'id': kw.get('id', '2bb8720a-0873-4d97-babf-0d906851a1eb'), + 'name': kw.get('name', 'lease_test'), + 'start_date': kw.get('start_date', '2014-01-01 01:23'), + 'end_date': kw.get('end_date', '2014-02-01 13:37'), + 'trust_id': kw.get('trust_id', + '35b17138b3644e6aa1318f3099c5be68'), + 'user_id': kw.get('user_id', 'efd8780712d24b389c705f5c2ac427ff'), + 'project_id': kw.get('project_id', + 'bd9431c18d694ad3803a8d4a6b89fd36'), + 'reservations': kw.get('reservations', [ { - u'resource_id': u'1234', - u'resource_type': u'virtual:instance' + 'resource_id': '1234', + 'resource_type': 'virtual:instance' } ]), - u'events': kw.get('events', []), - u'status': kw.get('status', 'ACTIVE'), + 'events': kw.get('events', []), + 'status': kw.get('status', 'ACTIVE'), } diff --git a/blazar/tests/api/v1/oshosts/test_v1_0.py b/blazar/tests/api/v1/oshosts/test_v1_0.py index d0422e45..c54a31fb 100644 --- a/blazar/tests/api/v1/oshosts/test_v1_0.py +++ b/blazar/tests/api/v1/oshosts/test_v1_0.py @@ -46,22 +46,22 @@ def make_app(): def fake_computehost(**kw): return { - u'id': kw.get('id', u'1'), - u'hypervisor_hostname': kw.get('hypervisor_hostname', u'host01'), - u'hypervisor_type': kw.get('hypervisor_type', u'QEMU'), - u'vcpus': kw.get('vcpus', 1), - u'hypervisor_version': kw.get('hypervisor_version', 1000000), - u'trust_id': kw.get('trust_id', - u'35b17138-b364-4e6a-a131-8f3099c5be68'), - u'memory_mb': kw.get('memory_mb', 8192), - u'local_gb': kw.get('local_gb', 50), - u'cpu_info': kw.get('cpu_info', - u"{\"vendor\": \"Intel\", \"model\": \"qemu32\", " - "\"arch\": \"x86_64\", \"features\": []," - " \"topology\": {\"cores\": 1}}", - ), - u'extra_capas': kw.get('extra_capas', - {u'vgpus': 2, u'fruits': u'bananas'}) + 'id': kw.get('id', '1'), + 'hypervisor_hostname': kw.get('hypervisor_hostname', 'host01'), + 'hypervisor_type': kw.get('hypervisor_type', 'QEMU'), + 'vcpus': kw.get('vcpus', 1), + 'hypervisor_version': kw.get('hypervisor_version', 1000000), + 'trust_id': kw.get('trust_id', + '35b17138-b364-4e6a-a131-8f3099c5be68'), + 'memory_mb': kw.get('memory_mb', 8192), + 'local_gb': kw.get('local_gb', 50), + 'cpu_info': kw.get('cpu_info', + "{\"vendor\": \"Intel\", \"model\": \"qemu32\", " + "\"arch\": \"x86_64\", \"features\": []," + " \"topology\": {\"cores\": 1}}", + ), + 'extra_capas': kw.get('extra_capas', + {'vgpus': 2, 'fruits': 'bananas'}) } diff --git a/blazar/tests/api/v2/test_hosts.py b/blazar/tests/api/v2/test_hosts.py index 14534bf1..50b61d1e 100644 --- a/blazar/tests/api/v2/test_hosts.py +++ b/blazar/tests/api/v2/test_hosts.py @@ -22,22 +22,22 @@ from blazar.utils import trusts def fake_computehost(**kw): return { - u'id': kw.get('id', u'1'), - u'hypervisor_hostname': kw.get('hypervisor_hostname', u'host01'), - u'hypervisor_type': kw.get('hypervisor_type', u'QEMU'), - u'vcpus': kw.get('vcpus', 1), - u'hypervisor_version': kw.get('hypervisor_version', 1000000), - u'trust_id': kw.get('trust_id', - u'35b17138-b364-4e6a-a131-8f3099c5be68'), - u'memory_mb': kw.get('memory_mb', 8192), - u'local_gb': kw.get('local_gb', 50), - u'cpu_info': kw.get('cpu_info', - u"{\"vendor\": \"Intel\", \"model\": \"qemu32\", " - "\"arch\": \"x86_64\", \"features\": []," - " \"topology\": {\"cores\": 1}}", - ), - u'extra_capas': kw.get('extra_capas', - {u'vgpus': 2, u'fruits': u'bananas'}), + 'id': kw.get('id', '1'), + 'hypervisor_hostname': kw.get('hypervisor_hostname', 'host01'), + 'hypervisor_type': kw.get('hypervisor_type', 'QEMU'), + 'vcpus': kw.get('vcpus', 1), + 'hypervisor_version': kw.get('hypervisor_version', 1000000), + 'trust_id': kw.get('trust_id', + '35b17138-b364-4e6a-a131-8f3099c5be68'), + 'memory_mb': kw.get('memory_mb', 8192), + 'local_gb': kw.get('local_gb', 50), + 'cpu_info': kw.get('cpu_info', + "{\"vendor\": \"Intel\", \"model\": \"qemu32\", " + "\"arch\": \"x86_64\", \"features\": []," + " \"topology\": {\"cores\": 1}}", + ), + 'extra_capas': kw.get('extra_capas', + {'vgpus': 2, 'fruits': 'bananas'}) } @@ -82,9 +82,9 @@ class TestIncorrectHostFromRPC(api.APITest): def test_bad_list(self): expected = { - u'error_code': 400, - u'error_message': u"Invalid input", - u'error_name': 400 + 'error_code': 400, + 'error_message': "Invalid input", + 'error_name': 400 } response = self.get_json(self.path, expect_errors=True, headers=self.headers) @@ -134,9 +134,9 @@ class TestListHosts(api.APITest): def fake_list_computehosts(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.hosts_rpcapi, 'list_computehosts' @@ -167,10 +167,10 @@ class TestShowHost(api.APITest): def test_empty(self): expected = { - u'error_code': 404, - u'error_message': u"Object with {{'host_id': " - u"{0}}} not found".format(self.id1), - u'error_name': 404 + 'error_code': 404, + 'error_message': "Object with {{'host_id': " + "{0}}} not found".format(self.id1), + 'error_name': 404 } self.patch(self.hosts_rpcapi, 'get_computehost').return_value = None response = self.get_json(self.path, expect_errors=True, @@ -183,9 +183,9 @@ class TestShowHost(api.APITest): def fake_get_computehost(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.hosts_rpcapi, 'get_computehost' @@ -254,9 +254,9 @@ class TestCreateHost(api.APITest): def test_empty_response(self): expected = { - u'error_code': 500, - u'error_message': u"Host can't be created", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Host can't be created", + 'error_name': 500 } self.patch(self.hosts_rpcapi, 'create_computehost').return_value = None response = self.post_json(self.path, self.fake_computehost_body, @@ -269,9 +269,9 @@ class TestCreateHost(api.APITest): def fake_create_computehost(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': u"Nah...", + 'error_name': 500 } self.patch( self.hosts_rpcapi, 'create_computehost' @@ -325,10 +325,10 @@ class TestUpdateHost(api.APITest): def test_empty_response(self): expected = { - u'error_code': 404, - u'error_message': u"Object with {{'host_id': " - u"{0}}} not found".format(self.id1), - u'error_name': 404 + 'error_code': 404, + 'error_message': "Object with {{'host_id': " + "{0}}} not found".format(self.id1), + 'error_name': 404 } self.patch(self.hosts_rpcapi, 'update_computehost').return_value = None response = self.put_json(self.path, self.fake_computehost_body, @@ -341,9 +341,9 @@ class TestUpdateHost(api.APITest): def fake_update_computehost(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': u"Nah...", + 'error_name': 500 } self.patch( self.hosts_rpcapi, 'update_computehost' @@ -375,9 +375,9 @@ class TestDeleteHost(api.APITest): def fake_delete_computehost(*args, **kwargs): raise TypeError("Nah...") expected = { - u'error_code': 404, - u'error_message': u"not found", - u'error_name': 404 + 'error_code': 404, + 'error_message': "not found", + 'error_name': 404 } self.patch( self.hosts_rpcapi, 'delete_computehost' @@ -395,9 +395,9 @@ class TestDeleteHost(api.APITest): def fake_delete_computehost(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': u"Nah...", + 'error_name': 500 } self.patch( self.hosts_rpcapi, 'delete_computehost' diff --git a/blazar/tests/api/v2/test_leases.py b/blazar/tests/api/v2/test_leases.py index b537561c..1bfac7c5 100644 --- a/blazar/tests/api/v2/test_leases.py +++ b/blazar/tests/api/v2/test_leases.py @@ -22,23 +22,23 @@ from blazar.utils import trusts def fake_lease(**kw): return { - u'id': kw.get('id', u'2bb8720a-0873-4d97-babf-0d906851a1eb'), - u'name': kw.get('name', u'lease_test'), - u'start_date': kw.get('start_date', u'2014-01-01 01:23'), - u'end_date': kw.get('end_date', u'2014-02-01 13:37'), - u'trust_id': kw.get('trust_id', - u'35b17138b3644e6aa1318f3099c5be68'), - u'user_id': kw.get('user_id', u'efd8780712d24b389c705f5c2ac427ff'), - u'project_id': kw.get('project_id', - u'bd9431c18d694ad3803a8d4a6b89fd36'), - u'reservations': kw.get('reservations', [ + 'id': kw.get('id', '2bb8720a-0873-4d97-babf-0d906851a1eb'), + 'name': kw.get('name', 'lease_test'), + 'start_date': kw.get('start_date', '2014-01-01 01:23'), + 'end_date': kw.get('end_date', '2014-02-01 13:37'), + 'trust_id': kw.get('trust_id', + '35b17138b3644e6aa1318f3099c5be68'), + 'user_id': kw.get('user_id', 'efd8780712d24b389c705f5c2ac427ff'), + 'project_id': kw.get('project_id', + 'bd9431c18d694ad3803a8d4a6b89fd36'), + 'reservations': kw.get('reservations', [ { - u'resource_id': u'1234', - u'resource_type': u'virtual:instance' + 'resource_id': '1234', + 'resource_type': 'virtual:instance' } ]), - u'events': kw.get('events', []), - u'status': kw.get('status', 'ACTIVE'), + 'events': kw.get('events', []), + 'status': kw.get('status', 'ACTIVE'), } @@ -70,10 +70,10 @@ class TestIncorrectLeaseFromRPC(api.APITest): def test_bad_list(self): expected = { - u'error_code': 400, - u'error_message': u"Invalid input for field/attribute id. " - u"Value: '1'. Value should be UUID format", - u'error_name': 400 + 'error_code': 400, + 'error_message': "Invalid input for field/attribute id. " + "Value: '1'. Value should be UUID format", + 'error_name': 400 } response = self.get_json(self.path, expect_errors=True) self.assertEqual(400, response.status_int) @@ -114,9 +114,9 @@ class TestListLeases(api.APITest): def fake_list_leases(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.rpcapi, 'list_leases').side_effect = fake_list_leases @@ -142,9 +142,9 @@ class TestShowLease(api.APITest): def test_empty(self): expected = { - u'error_code': 404, - u'error_message': u"not found", - u'error_name': 404 + 'error_code': 404, + 'error_message': "not found", + 'error_name': 404 } self.patch(self.rpcapi, 'get_lease').return_value = None response = self.get_json(self.path, expect_errors=True) @@ -159,9 +159,9 @@ class TestShowLease(api.APITest): def fake_get_lease(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.rpcapi, 'get_lease').side_effect = fake_get_lease @@ -221,9 +221,9 @@ class TestCreateLease(api.APITest): def test_empty_response(self): expected = { - u'error_code': 500, - u'error_message': u"Lease can't be created", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Lease can't be created", + 'error_name': 500 } self.patch(self.rpcapi, 'create_lease').return_value = None response = self.post_json(self.path, self.fake_lease_body, @@ -236,9 +236,9 @@ class TestCreateLease(api.APITest): def fake_create_lease(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.rpcapi, 'create_lease').side_effect = fake_create_lease @@ -298,9 +298,9 @@ class TestUpdateLease(api.APITest): def test_empty_response(self): expected = { - u'error_code': 404, - u'error_message': u"not found", - u'error_name': 404 + 'error_code': 404, + 'error_message': "not found", + 'error_name': 404 } self.patch(self.rpcapi, 'update_lease').return_value = None response = self.put_json(self.path, self.fake_lease_body, @@ -316,9 +316,9 @@ class TestUpdateLease(api.APITest): def fake_update_lease(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.rpcapi, 'update_lease').side_effect = fake_update_lease @@ -348,9 +348,9 @@ class TestDeleteLease(api.APITest): def fake_delete_lease(*args, **kwargs): raise TypeError("Nah...") expected = { - u'error_code': 404, - u'error_message': u"not found", - u'error_name': 404 + 'error_code': 404, + 'error_message': "not found", + 'error_name': 404 } self.patch( self.rpcapi, 'delete_lease').side_effect = fake_delete_lease @@ -366,9 +366,9 @@ class TestDeleteLease(api.APITest): def fake_delete_lease(*args, **kwargs): raise Exception("Nah...") expected = { - u'error_code': 500, - u'error_message': u"Nah...", - u'error_name': 500 + 'error_code': 500, + 'error_message': "Nah...", + 'error_name': 500 } self.patch( self.rpcapi, 'delete_lease').side_effect = fake_delete_lease diff --git a/blazar/tests/fake_lease.py b/blazar/tests/fake_lease.py index 05b1b6f8..47aeb75f 100644 --- a/blazar/tests/fake_lease.py +++ b/blazar/tests/fake_lease.py @@ -14,16 +14,16 @@ lease_data = {'id': '1', - 'name': u'lease_test', - 'start_date': u'2014-01-01 01:23', - 'end_date': u'2014-02-01 13:37', - 'user_id': u'efd8780712d24b389c705f5c2ac427ff', - 'project_id': u'bd9431c18d694ad3803a8d4a6b89fd36', - 'trust_id': u'35b17138b3644e6aa1318f3099c5be68', - 'reservations': [{u'resource_id': u'1234', - u'resource_type': u'virtual:instance'}], + 'name': 'lease_test', + 'start_date': '2014-01-01 01:23', + 'end_date': '2014-02-01 13:37', + 'user_id': 'efd8780712d24b389c705f5c2ac427ff', + 'project_id': 'bd9431c18d694ad3803a8d4a6b89fd36', + 'trust_id': '35b17138b3644e6aa1318f3099c5be68', + 'reservations': [{'resource_id': '1234', + 'resource_type': 'virtual:instance'}], 'events': [], - 'before_end_date': u'2014-02-01 10:37', + 'before_end_date': '2014-02-01 10:37', 'action': None, 'status': None, 'status_reason': None} diff --git a/blazar/tests/manager/test_service.py b/blazar/tests/manager/test_service.py index 168f5fe9..90c9c263 100644 --- a/blazar/tests/manager/test_service.py +++ b/blazar/tests/manager/test_service.py @@ -781,12 +781,12 @@ class ServiceTestCase(tests.TestCase): def test_update_lease_not_started_modify_dates(self): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': delta = datetime.timedelta(hours=1) - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': self.lease['end_date'] - delta, 'status': 'UNDONE'} @@ -799,7 +799,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', } ] @@ -832,19 +832,19 @@ class ServiceTestCase(tests.TestCase): def test_update_modify_reservations(self): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': delta = datetime.timedelta(hours=1) - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': self.lease['end_date'] - delta, 'status': 'UNDONE'} lease_values = { 'reservations': [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'min': 3, 'max': 3 } @@ -854,7 +854,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', } ] @@ -872,7 +872,7 @@ class ServiceTestCase(tests.TestCase): { 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00), - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'min': 3, 'max': 3 } @@ -891,7 +891,7 @@ class ServiceTestCase(tests.TestCase): lease_values = { 'reservations': [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'invalid', 'min': 3, 'max': 3 @@ -902,7 +902,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', } ] @@ -927,7 +927,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', } ] @@ -955,11 +955,11 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', }, { - 'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1', + 'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1', 'resource_type': 'virtual:instance', } ] @@ -975,9 +975,9 @@ class ServiceTestCase(tests.TestCase): def test_update_lease_started_modify_end_date_without_before_end(self): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} else: return None @@ -989,7 +989,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1022,12 +1022,12 @@ class ServiceTestCase(tests.TestCase): def test_update_lease_started_modify_end_date_and_before_end(self): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': delta = datetime.timedelta(hours=1) - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': self.lease['end_date'] - delta, 'status': 'DONE'} @@ -1039,7 +1039,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1087,11 +1087,11 @@ class ServiceTestCase(tests.TestCase): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': before_end_date, 'status': 'DONE'} @@ -1104,7 +1104,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1157,11 +1157,11 @@ class ServiceTestCase(tests.TestCase): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': before_end_date, 'status': 'DONE'} @@ -1174,7 +1174,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': expected_start_date, 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1197,11 +1197,11 @@ class ServiceTestCase(tests.TestCase): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': before_end_date, 'status': 'DONE'} @@ -1214,7 +1214,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1236,11 +1236,11 @@ class ServiceTestCase(tests.TestCase): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} elif filters['event_type'] == 'end_lease': - return {'id': u'7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} + return {'id': '7085381b-45e0-4e5d-b24a-f965f5e6e5d7'} elif filters['event_type'] == 'before_end_lease': - return {'id': u'452bf850-e223-4035-9d13-eb0b0197228f', + return {'id': '452bf850-e223-4035-9d13-eb0b0197228f', 'time': wrong_before_end_date, 'status': 'DONE'} @@ -1253,7 +1253,7 @@ class ServiceTestCase(tests.TestCase): self.patch(self.db_api, 'reservation_get_all_by_lease_id')) reservation_get_all.return_value = [ { - 'id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'resource_type': 'virtual:instance', 'start_date': datetime.datetime(2013, 12, 20, 13, 00), 'end_date': datetime.datetime(2013, 12, 20, 15, 00) @@ -1347,7 +1347,7 @@ class ServiceTestCase(tests.TestCase): def test_update_lease_end_date_event_not_found(self): def fake_event_get(sort_key, sort_dir, filters): if filters['event_type'] == 'start_lease': - return {'id': u'2eeb784a-2d84-4a89-a201-9d42d61eecb1'} + return {'id': '2eeb784a-2d84-4a89-a201-9d42d61eecb1'} else: return None diff --git a/blazar/tests/plugins/floatingips/test_floatingip_plugin.py b/blazar/tests/plugins/floatingips/test_floatingip_plugin.py index e16b11a0..351f15ca 100644 --- a/blazar/tests/plugins/floatingips/test_floatingip_plugin.py +++ b/blazar/tests/plugins/floatingips/test_floatingip_plugin.py @@ -192,8 +192,8 @@ class FloatingIpPluginTest(tests.TestCase): def test_create_reservation_fips_available(self): fip_plugin = floatingip_plugin.FloatingIpPlugin() values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', - 'network_id': u'f548089e-fb3e-4013-a043-c5ed809c7a67', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', + 'network_id': 'f548089e-fb3e-4013-a043-c5ed809c7a67', 'start_date': datetime.datetime(2013, 12, 19, 20, 0), 'end_date': datetime.datetime(2013, 12, 19, 21, 0), 'resource_type': plugin.RESOURCE_TYPE, @@ -206,22 +206,22 @@ class FloatingIpPluginTest(tests.TestCase): fip_allocation_create = self.patch( self.db_api, 'fip_allocation_create') fip_plugin.reserve_resource( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) fip_values = { - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', - 'network_id': u'f548089e-fb3e-4013-a043-c5ed809c7a67', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'network_id': 'f548089e-fb3e-4013-a043-c5ed809c7a67', 'amount': 2 } fip_reservation_create.assert_called_once_with(fip_values) calls = [ mock.call( {'floatingip_id': 'fip1', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), mock.call( {'floatingip_id': 'fip2', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), ] fip_allocation_create.assert_has_calls(calls) @@ -229,8 +229,8 @@ class FloatingIpPluginTest(tests.TestCase): def test_create_reservation_fips_with_required(self): fip_plugin = floatingip_plugin.FloatingIpPlugin() values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', - 'network_id': u'f548089e-fb3e-4013-a043-c5ed809c7a67', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', + 'network_id': 'f548089e-fb3e-4013-a043-c5ed809c7a67', 'start_date': datetime.datetime(2013, 12, 19, 20, 0), 'end_date': datetime.datetime(2013, 12, 19, 21, 0), 'resource_type': plugin.RESOURCE_TYPE, @@ -246,11 +246,11 @@ class FloatingIpPluginTest(tests.TestCase): self.db_api, 'fip_allocation_create') required_addr_create = self.patch(self.db_api, 'required_fip_create') fip_plugin.reserve_resource( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) fip_values = { - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', - 'network_id': u'f548089e-fb3e-4013-a043-c5ed809c7a67', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'network_id': 'f548089e-fb3e-4013-a043-c5ed809c7a67', 'amount': 2 } fip_reservation_create.assert_called_once_with(fip_values) @@ -262,18 +262,18 @@ class FloatingIpPluginTest(tests.TestCase): calls = [ mock.call( {'floatingip_id': 'fip1', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), mock.call( {'floatingip_id': 'fip2', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), ] fip_allocation_create.assert_has_calls(calls) def test_create_reservation_with_missing_param_network(self): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'amount': 2, 'start_date': datetime.datetime(2017, 3, 1, 20, 0), 'end_date': datetime.datetime(2017, 3, 2, 20, 0), @@ -283,13 +283,13 @@ class FloatingIpPluginTest(tests.TestCase): self.assertRaises( mgr_exceptions.MissingParameter, fip_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) def test_create_reservation_with_invalid_fip(self): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', - 'network_id': u'a37a14f3-e3eb-4fe2-9e36-082b67f12ea0', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', + 'network_id': 'a37a14f3-e3eb-4fe2-9e36-082b67f12ea0', 'amount': 2, 'required_floatingips': ['aaa.aaa.aaa.aaa'], 'start_date': datetime.datetime(2017, 3, 1, 20, 0), @@ -300,13 +300,13 @@ class FloatingIpPluginTest(tests.TestCase): self.assertRaises( mgr_exceptions.InvalidIPFormat, fip_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) def test_create_reservation_required_bigger_than_amount(self): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', - 'network_id': u'a37a14f3-e3eb-4fe2-9e36-082b67f12ea0', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', + 'network_id': 'a37a14f3-e3eb-4fe2-9e36-082b67f12ea0', 'amount': 1, 'required_floatingips': ['172.24.4.100', '172.24.4.101'], 'start_date': datetime.datetime(2017, 3, 1, 20, 0), @@ -317,7 +317,7 @@ class FloatingIpPluginTest(tests.TestCase): self.assertRaises( mgr_exceptions.TooLongFloatingIPs, fip_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) def test_update_pending_reservation_increase_amount_fips_available(self): @@ -363,14 +363,14 @@ class FloatingIpPluginTest(tests.TestCase): fip_allocation_create = self.patch( self.db_api, 'fip_allocation_create') fip_plugin.update_reservation( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) fip_reservation_update.assert_called_once_with( 'fip_resv_id1', {'amount': 2}) calls = [ mock.call( {'floatingip_id': 'fip2', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }) ] fip_allocation_create.assert_has_calls(calls) @@ -429,7 +429,7 @@ class FloatingIpPluginTest(tests.TestCase): fip_allocation_destroy = self.patch( self.db_api, 'fip_allocation_destroy') fip_plugin.update_reservation( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) fip_reservation_update.assert_called_once_with( 'fip_resv_id1', {'amount': 2}) @@ -443,7 +443,7 @@ class FloatingIpPluginTest(tests.TestCase): calls = [ mock.call( {'floatingip_id': 'fip2', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }) ] fip_allocation_create.assert_has_calls(calls) @@ -611,7 +611,7 @@ class FloatingIpPluginTest(tests.TestCase): fip_reservation_update = self.patch(self.db_api, 'fip_reservation_update') fip_plugin.update_reservation( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) fip_reservation_update.assert_called_once_with( 'fip_resv_id1', {'amount': 1}) @@ -659,7 +659,7 @@ class FloatingIpPluginTest(tests.TestCase): required_fip_destroy_by_fip_reservation_id = self.patch( self.db_api, 'required_fip_destroy_by_fip_reservation_id') fip_plugin.update_reservation( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) calls = [mock.call('fip_resv_id1')] required_fip_destroy_by_fip_reservation_id.assert_has_calls(calls) diff --git a/blazar/tests/plugins/oshosts/test_physical_host_plugin.py b/blazar/tests/plugins/oshosts/test_physical_host_plugin.py index 9b47b4f5..79e131ca 100644 --- a/blazar/tests/plugins/oshosts/test_physical_host_plugin.py +++ b/blazar/tests/plugins/oshosts/test_physical_host_plugin.py @@ -392,7 +392,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'host_allocation_get_all_by_values') host_allocation_get_all.return_value = [ { - 'id': u'dd305477-4df8-4547-87f6-69069ee546a6', + 'id': 'dd305477-4df8-4547-87f6-69069ee546a6', 'compute_host_id': self.fake_host_id } ] @@ -644,7 +644,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): def test_create_reservation_no_hosts_available(self): now = datetime.datetime.utcnow() values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 1, 'max': 1, 'hypervisor_properties': '["=", "$memory_mb", "256"]', @@ -659,14 +659,14 @@ class PhysicalHostPluginTestCase(tests.TestCase): matching_hosts.return_value = [] self.assertRaises(manager_exceptions.NotEnoughHostsAvailable, self.fake_phys_plugin.reserve_resource, - u'f9894fcf-e2ed-41e9-8a4c-92fac332608e', + 'f9894fcf-e2ed-41e9-8a4c-92fac332608e', values) self.rp_create.assert_not_called() host_reservation_create.assert_not_called() def test_create_reservation_hosts_available(self): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 1, 'max': 1, 'hypervisor_properties': '["=", "$memory_mb", "256"]', @@ -684,10 +684,10 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.db_api, 'host_allocation_create') self.fake_phys_plugin.reserve_resource( - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) host_values = { - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', 'aggregate_id': 1, 'resource_properties': '', 'hypervisor_properties': '["=", "$memory_mb", "256"]', @@ -699,11 +699,11 @@ class PhysicalHostPluginTestCase(tests.TestCase): calls = [ mock.call( {'compute_host_id': 'host1', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), mock.call( {'compute_host_id': 'host2', - 'reservation_id': u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + 'reservation_id': '441c1476-9f8f-4700-9f30-cd9b6fef3509', }), ] host_allocation_create.assert_has_calls(calls) @@ -711,7 +711,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): @ddt.data("min", "max", "hypervisor_properties", "resource_properties") def test_create_reservation_with_missing_param(self, missing_param): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 1, 'max': 2, 'before_end': 'default', @@ -724,7 +724,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.assertRaises( manager_exceptions.MissingParameter, self.fake_phys_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) @ddt.data({"params": {'max': 0}}, @@ -737,7 +737,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): @ddt.unpack def test_create_reservation_with_invalid_param(self, params): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 1, 'max': 2, 'before_end': 'default', @@ -751,7 +751,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.assertRaises( manager_exceptions.MalformedParameter, self.fake_phys_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) @ddt.data({"params": {'max': 0}}, @@ -763,7 +763,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): @ddt.unpack def test_update_reservation_with_invalid_param(self, params): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 1, 'max': 2, 'before_end': 'default', @@ -786,12 +786,12 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.assertRaises( manager_exceptions.MalformedParameter, self.fake_phys_plugin.update_reservation, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) def test_create_update_reservation_with_invalid_range(self): values = { - 'lease_id': u'018c1b43-e69e-4aef-a543-09681539cf4c', + 'lease_id': '018c1b43-e69e-4aef-a543-09681539cf4c', 'min': 2, 'max': 1, 'hypervisor_properties': '["=", "$memory_mb", "256"]', @@ -812,12 +812,12 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.assertRaises( manager_exceptions.InvalidRange, self.fake_phys_plugin.reserve_resource, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) self.assertRaises( manager_exceptions.InvalidRange, self.fake_phys_plugin.update_reservation, - u'441c1476-9f8f-4700-9f30-cd9b6fef3509', + '441c1476-9f8f-4700-9f30-cd9b6fef3509', values) def test_update_reservation_shorten(self): @@ -827,7 +827,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): } reservation_get = self.patch(self.db_api, 'reservation_get') reservation_get.return_value = { - 'lease_id': u'10870923-6d56-45c9-b592-f788053f5baa', + 'lease_id': '10870923-6d56-45c9-b592-f788053f5baa', } lease_get = self.patch(self.db_api, 'lease_get') lease_get.return_value = { @@ -848,8 +848,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): } reservation_get = self.patch(self.db_api, 'reservation_get') reservation_get.return_value = { - 'lease_id': u'10870923-6d56-45c9-b592-f788053f5baa', - 'resource_id': u'91253650-cc34-4c4f-bbe8-c943aa7d0c9b', + 'lease_id': '10870923-6d56-45c9-b592-f788053f5baa', + 'resource_id': '91253650-cc34-4c4f-bbe8-c943aa7d0c9b', 'status': 'pending' } lease_get = self.patch(self.db_api, 'lease_get') @@ -868,7 +868,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'host_allocation_get_all_by_values') host_allocation_get_all.return_value = [ { - 'id': u'dd305477-4df8-4547-87f6-69069ee546a6', + 'id': 'dd305477-4df8-4547-87f6-69069ee546a6', 'compute_host_id': 'host1' } ] @@ -901,8 +901,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): } reservation_get = self.patch(self.db_api, 'reservation_get') reservation_get.return_value = { - 'lease_id': u'10870923-6d56-45c9-b592-f788053f5baa', - 'resource_id': u'91253650-cc34-4c4f-bbe8-c943aa7d0c9b', + 'lease_id': '10870923-6d56-45c9-b592-f788053f5baa', + 'resource_id': '91253650-cc34-4c4f-bbe8-c943aa7d0c9b', 'status': 'active' } lease_get = self.patch(self.db_api, 'lease_get') @@ -923,7 +923,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'host_allocation_get_all_by_values') host_allocation_get_all.return_value = [ { - 'id': u'dd305477-4df8-4547-87f6-69069ee546a6', + 'id': 'dd305477-4df8-4547-87f6-69069ee546a6', 'compute_host_id': 'host1' } ] @@ -955,8 +955,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): } reservation_get = self.patch(self.db_api, 'reservation_get') reservation_get.return_value = { - 'lease_id': u'10870923-6d56-45c9-b592-f788053f5baa', - 'resource_id': u'91253650-cc34-4c4f-bbe8-c943aa7d0c9b', + 'lease_id': '10870923-6d56-45c9-b592-f788053f5baa', + 'resource_id': '91253650-cc34-4c4f-bbe8-c943aa7d0c9b', 'status': 'pending' } lease_get = self.patch(self.db_api, 'lease_get') @@ -977,7 +977,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'host_allocation_get_all_by_values') host_allocation_get_all.return_value = [ { - 'id': u'dd305477-4df8-4547-87f6-69069ee546a6', + 'id': 'dd305477-4df8-4547-87f6-69069ee546a6', 'compute_host_id': 'host1' } ] @@ -1010,8 +1010,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): } reservation_get = self.patch(self.db_api, 'reservation_get') reservation_get.return_value = { - 'lease_id': u'10870923-6d56-45c9-b592-f788053f5baa', - 'resource_id': u'91253650-cc34-4c4f-bbe8-c943aa7d0c9b', + 'lease_id': '10870923-6d56-45c9-b592-f788053f5baa', + 'resource_id': '91253650-cc34-4c4f-bbe8-c943aa7d0c9b', 'status': 'pending' } lease_get = self.patch(self.db_api, 'lease_get') @@ -1033,7 +1033,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'host_allocation_get_all_by_values') host_allocation_get_all.return_value = [ { - 'id': u'dd305477-4df8-4547-87f6-69069ee546a6', + 'id': 'dd305477-4df8-4547-87f6-69069ee546a6', 'compute_host_id': 'host1' } ] @@ -1059,7 +1059,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): '706eb3bc-07ed-4383-be93-b32845ece672', values) host_reservation_get.assert_called_with( - u'91253650-cc34-4c4f-bbe8-c943aa7d0c9b') + '91253650-cc34-4c4f-bbe8-c943aa7d0c9b') host_allocation_destroy.assert_called_with( 'dd305477-4df8-4547-87f6-69069ee546a6') host_allocation_create.assert_called_with( @@ -1363,7 +1363,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): 'count_range': '1-2', 'hypervisor_properties': '["=", "$memory_mb", "16384"]', 'resource_properties': '', - 'reservation_id': u'706eb3bc-07ed-4383-be93-b32845ece672', + 'reservation_id': '706eb3bc-07ed-4383-be93-b32845ece672', 'aggregate_id': 1, } host_allocation_get_all = self.patch( @@ -1663,7 +1663,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): def test_on_start(self): host_reservation_get = self.patch(self.db_api, 'host_reservation_get') host_reservation_get.return_value = { - 'reservation_id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'reservation_id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'aggregate_id': 1, } host_allocation_get_all_by_values = self.patch( @@ -1676,7 +1676,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): add_computehost = self.patch( self.nova.ReservationPool, 'add_computehost') - self.fake_phys_plugin.on_start(u'04de74e8-193a-49d2-9ab8-cba7b49e45e8') + self.fake_phys_plugin.on_start('04de74e8-193a-49d2-9ab8-cba7b49e45e8') add_computehost.assert_called_with(1, ['host1_hostname']) @@ -1685,7 +1685,7 @@ class PhysicalHostPluginTestCase(tests.TestCase): host_reservation_get.return_value = {'before_end': ''} reservationpool = self.patch(self.nova, 'ReservationPool') self.fake_phys_plugin.before_end( - u'04de74e8-193a-49d2-9ab8-cba7b49e45e8') + '04de74e8-193a-49d2-9ab8-cba7b49e45e8') reservationpool.assert_not_called() def test_before_end_with_snapshot(self): @@ -1701,15 +1701,15 @@ class PhysicalHostPluginTestCase(tests.TestCase): list_servers.return_value = ['server1', 'server2'] create_image = self.patch(self.ServerManager, 'create_image') self.fake_phys_plugin.before_end( - u'04de74e8-193a-49d2-9ab8-cba7b49e45e8') + '04de74e8-193a-49d2-9ab8-cba7b49e45e8') create_image.assert_any_call(server='server1') create_image.assert_any_call(server='server2') def test_on_end_with_instances(self): host_reservation_get = self.patch(self.db_api, 'host_reservation_get') host_reservation_get.return_value = { - 'id': u'04de74e8-193a-49d2-9ab8-cba7b49e45e8', - 'reservation_id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '04de74e8-193a-49d2-9ab8-cba7b49e45e8', + 'reservation_id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'aggregate_id': 1 } host_reservation_update = self.patch( @@ -1719,8 +1719,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.db_api, 'host_allocation_get_all_by_values') host_allocation_get_all_by_values.return_value = [ - {'id': u'bfa9aa0b-8042-43eb-a4e6-4555838bf64f', - 'compute_host_id': u'cdae2a65-236f-475a-977d-f6ad82f828b7', + {'id': 'bfa9aa0b-8042-43eb-a4e6-4555838bf64f', + 'compute_host_id': 'cdae2a65-236f-475a-977d-f6ad82f828b7', }, ] host_allocation_destroy = self.patch( @@ -1738,11 +1738,11 @@ class PhysicalHostPluginTestCase(tests.TestCase): side_effect=[nova_exceptions.NotFound( 404, 'Instance server1 could not be found.'), None]) delete_pool = self.patch(self.nova.ReservationPool, 'delete') - self.fake_phys_plugin.on_end(u'04de74e8-193a-49d2-9ab8-cba7b49e45e8') + self.fake_phys_plugin.on_end('04de74e8-193a-49d2-9ab8-cba7b49e45e8') host_reservation_update.assert_called_with( - u'04de74e8-193a-49d2-9ab8-cba7b49e45e8', {'status': 'completed'}) + '04de74e8-193a-49d2-9ab8-cba7b49e45e8', {'status': 'completed'}) host_allocation_destroy.assert_called_with( - u'bfa9aa0b-8042-43eb-a4e6-4555838bf64f') + 'bfa9aa0b-8042-43eb-a4e6-4555838bf64f') list_servers.assert_called_with(search_opts={'host': 'host', 'all_tenants': 1}) delete_server.assert_any_call(server='server1') @@ -1752,8 +1752,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): def test_on_end_without_instances(self): host_reservation_get = self.patch(self.db_api, 'host_reservation_get') host_reservation_get.return_value = { - 'id': u'04de74e8-193a-49d2-9ab8-cba7b49e45e8', - 'reservation_id': u'593e7028-c0d1-4d76-8642-2ffd890b324c', + 'id': '04de74e8-193a-49d2-9ab8-cba7b49e45e8', + 'reservation_id': '593e7028-c0d1-4d76-8642-2ffd890b324c', 'aggregate_id': 1 } host_reservation_update = self.patch( @@ -1763,8 +1763,8 @@ class PhysicalHostPluginTestCase(tests.TestCase): self.db_api, 'host_allocation_get_all_by_values') host_allocation_get_all_by_values.return_value = [ - {'id': u'bfa9aa0b-8042-43eb-a4e6-4555838bf64f', - 'compute_host_id': u'cdae2a65-236f-475a-977d-f6ad82f828b7', + {'id': 'bfa9aa0b-8042-43eb-a4e6-4555838bf64f', + 'compute_host_id': 'cdae2a65-236f-475a-977d-f6ad82f828b7', }, ] host_allocation_destroy = self.patch( @@ -1777,11 +1777,11 @@ class PhysicalHostPluginTestCase(tests.TestCase): list_servers.return_value = [] delete_server = self.patch(self.ServerManager, 'delete') delete_pool = self.patch(self.nova.ReservationPool, 'delete') - self.fake_phys_plugin.on_end(u'04de74e8-193a-49d2-9ab8-cba7b49e45e8') + self.fake_phys_plugin.on_end('04de74e8-193a-49d2-9ab8-cba7b49e45e8') host_reservation_update.assert_called_with( - u'04de74e8-193a-49d2-9ab8-cba7b49e45e8', {'status': 'completed'}) + '04de74e8-193a-49d2-9ab8-cba7b49e45e8', {'status': 'completed'}) host_allocation_destroy.assert_called_with( - u'bfa9aa0b-8042-43eb-a4e6-4555838bf64f') + 'bfa9aa0b-8042-43eb-a4e6-4555838bf64f') delete_server.assert_not_called() delete_pool.assert_called_with(1) diff --git a/blazar/tests/test_context.py b/blazar/tests/test_context.py index 57d1be30..edaf68ae 100644 --- a/blazar/tests/test_context.py +++ b/blazar/tests/test_context.py @@ -46,7 +46,7 @@ class TestBlazarContext(tests.TestCase): 'user': 111, 'user_domain': None, 'user_id': 111, - 'user_identity': u'111 222 - - -', + 'user_identity': '111 222 - - -', 'user_name': None} self.assertEqual(expected, ctx.to_dict()) diff --git a/doc/source/conf.py b/doc/source/conf.py index a912457b..0961b022 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -69,7 +69,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -copyright = u'2013-present, OpenStack Foundation' +copyright = '2013-present, OpenStack Foundation' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -190,8 +190,8 @@ htmlhelp_basename = 'BlazarDoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'doc-blazar.tex', u'Blazar Documentation', - u'OpenStack Foundation', 'manual'), + ('index', 'doc-blazar.tex', 'Blazar Documentation', + 'OpenStack Foundation', 'manual'), ] # Disable usage of xindy https://bugzilla.redhat.com/show_bug.cgi?id=1643664 @@ -223,8 +223,8 @@ latex_use_xindy = False # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'blazar', u'Blazar', - [u'OpenStack Foundation'], 1) + ('index', 'blazar', 'Blazar', + ['OpenStack Foundation'], 1) ] # If true, show URL addresses after external links. @@ -237,8 +237,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'Blazar', u'Blazar', - u'OpenStack Foundation', 'Blazar', 'Blazar', + ('index', 'Blazar', 'Blazar', + 'OpenStack Foundation', 'Blazar', 'Blazar', 'Miscellaneous'), ] diff --git a/releasenotes/source/conf.py b/releasenotes/source/conf.py index 3c5d62ba..8e453edc 100644 --- a/releasenotes/source/conf.py +++ b/releasenotes/source/conf.py @@ -58,7 +58,7 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -copyright = u'2017, Blazar developers' +copyright = '2017, Blazar developers' # Release notes are version independent. # The short X.Y version. @@ -193,8 +193,8 @@ htmlhelp_basename = 'BlazarReleaseNotesdoc' # author, documentclass [howto, manual, or own class]). latex_documents = [ ('index', 'BlazarReleaseNotes.tex', - u'Blazar Release Notes Documentation', - u'Blazar developers', 'manual'), + 'Blazar Release Notes Documentation', + 'Blazar developers', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -223,8 +223,8 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'blazarreleasenotes', u'Blazar Release Notes Documentation', - [u'Blazar developers'], 1) + ('index', 'blazarreleasenotes', 'Blazar Release Notes Documentation', + ['Blazar developers'], 1) ] # If true, show URL addresses after external links. @@ -237,8 +237,8 @@ man_pages = [ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'BlazarReleaseNotes', u'Blazar Release Notes Documentation', - u'Blazar developers', 'BlazarReleaseNotes', + ('index', 'BlazarReleaseNotes', 'Blazar Release Notes Documentation', + 'Blazar developers', 'BlazarReleaseNotes', 'One line description of project.', 'Miscellaneous'), ]