Merge "Remove six and python 2.7 full support"

This commit is contained in:
Zuul 2020-05-03 04:48:02 +00:00 committed by Gerrit Code Review
commit ed7638fa15
10 changed files with 59 additions and 68 deletions

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
import heat.api.middleware.fault as fault
import heat.api.openstack.v1.build_info as build_info
@ -72,4 +71,4 @@ class BuildInfoControllerTest(tools.ControllerTest, common.HeatTestCase):
self.controller.build_info,
req, tenant_id=self.tenant)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
import webob.exc
import heat.api.middleware.fault as fault
@ -341,7 +340,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=stack_identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_index_resource_nonexist(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'index', True)
@ -424,7 +423,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_name=sid.stack_name,
stack_id=sid.stack_id)
self.assertEqual("Only integer is acceptable by 'limit'.",
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
@mock.patch.object(rpc_client.EngineClient, 'call')
@ -631,7 +630,7 @@ class EventControllerTest(tools.ControllerTest, common.HeatTestCase):
event_id=event_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
@mock.patch.object(rpc_client.EngineClient, 'call')
def test_show_multiple_resource_names(self, mock_call, mock_enforce):

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
import webob.exc
import heat.api.middleware.fault as fault
@ -147,8 +146,8 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=stack_identity.stack_id)
self.assertIn("Invalid filter parameters %s" %
[six.text_type('invalid_key')],
six.text_type(ex))
[str('invalid_key')],
str(ex))
self.assertFalse(mock_call.called)
def test_index_nested_depth(self, mock_enforce):
@ -192,7 +191,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=stack_identity.stack_id)
self.assertEqual("Only integer is acceptable by 'nested_depth'.",
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
def test_index_denied_policy(self, mock_enforce):
@ -213,7 +212,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=stack_identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_index_detail(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'index', True)
@ -562,7 +561,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
resource_name=res_name)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_metadata_show(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'metadata', True)
@ -693,7 +692,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
resource_name=res_name)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_signal(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'signal', True)
@ -808,9 +807,9 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
resource_name=res_name,
body=body)
self.assertIn(expected, six.text_type(actual))
self.assertIn('invalid_key1', six.text_type(actual))
self.assertIn('invalid_key2', six.text_type(actual))
self.assertIn(expected, str(actual))
self.assertIn('invalid_key1', str(actual))
self.assertIn('invalid_key2', str(actual))
mock_call.assert_not_called()
def test_mark_unhealthy_with_invalid_value(self, mock_enforce):
@ -837,7 +836,7 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
resource_name=res_name,
body=body)
self.assertIn(expected, six.text_type(actual))
self.assertIn(expected, str(actual))
mock_call.assert_not_called()
def test_mark_unhealthy_without_mark_unhealthy_key(self, mock_enforce):
@ -863,5 +862,5 @@ class ResourceControllerTest(tools.ControllerTest, common.HeatTestCase):
resource_name=res_name,
body=body)
self.assertIn(expected, six.text_type(actual))
self.assertIn(expected, str(actual))
mock_call.assert_not_called()

View File

@ -15,7 +15,6 @@ import json
import mock
from oslo_config import cfg
import six
import webob.exc
import heat.api.middleware.fault as fault
@ -61,7 +60,7 @@ parameters:
template_format.parse(bad_temp)
parse_ex = self.assertRaises(webob.exc.HTTPBadRequest, generate_error)
self.assertIn('foo', six.text_type(parse_ex))
self.assertIn('foo', str(parse_ex))
def test_stack_name(self):
body = {'stack_name': 'wibble'}
@ -148,7 +147,7 @@ blarg: wibble
'bytes) exceeds maximum allowed size (%(limit)s bytes).') % {
'actual_len': len(str(template)),
'limit': cfg.CONF.max_template_size}
self.assertEqual(msg, six.text_type(error))
self.assertEqual(msg, str(error))
def test_parameters(self):
params = {'foo': 'bar', 'blarg': 'wibble'}
@ -348,7 +347,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
self.controller.index, req,
tenant_id=self.tenant)
self.assertEqual("Only integer is acceptable by 'limit'.",
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
@mock.patch.object(rpc_client.EngineClient, 'call')
@ -444,7 +443,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant)
excepted = ('Unrecognized value "invalid_value" for "with_count", '
'acceptable values are: true, false')
self.assertIn(excepted, six.text_type(exc))
self.assertIn(excepted, str(exc))
@mock.patch.object(rpc_client.EngineClient, 'count_stacks')
def test_index_doesnt_break_with_old_engine(self, mock_count_stacks,
@ -701,7 +700,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
@mock.patch.object(rpc_client.EngineClient, 'call')
def test_index_rmt_interr(self, mock_call, mock_enforce):
@ -900,7 +899,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
tenant_id=self.tenant, body=body)
self.assertEqual("Only integer is acceptable by 'timeout_mins'.",
six.text_type(ex))
str(ex))
mock_call.assert_not_called()
def test_adopt_error(self, mock_enforce):
@ -1106,7 +1105,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
tenant_id=self.tenant, body=body)
self.assertEqual("Only integer is acceptable by 'timeout_mins'.",
six.text_type(ex))
str(ex))
mock_call.assert_not_called()
def test_create_err_denied_policy(self, mock_enforce):
@ -1127,7 +1126,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
body=body)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_create_err_engine(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'create', True)
@ -1365,7 +1364,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
self.assertEqual('ImmutableParameterModified',
resp.json['error']['type'])
self.assertIn("The following parameters are immutable",
six.text_type(resp.json['error']['message']))
str(resp.json['error']['message']))
mock_call.assert_called_once_with(
req.context,
@ -1452,7 +1451,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_name=stack_name)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_lookup_resource(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'lookup', True)
@ -1514,7 +1513,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
path='resources')
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_show(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'show', True)
@ -1688,7 +1687,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_show_err_denied_policy(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'show', False)
@ -1703,7 +1702,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_get_template(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'template', True)
@ -1780,7 +1779,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_get_template_err_notfound(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'template', True)
@ -1954,7 +1953,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id,
body=body)
self.assertEqual("Only integer is acceptable by 'timeout_mins'.",
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
def test_update_err_denied_policy(self, mock_enforce):
@ -1978,7 +1977,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
body=body)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_update_with_existing_template(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'update_patch', True)
@ -2167,7 +2166,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id,
body=body)
self.assertEqual("Only integer is acceptable by 'timeout_mins'.",
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
def test_update_with_existing_and_default_parameters(
@ -2295,7 +2294,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_export(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'export', True)
@ -2354,7 +2353,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
stack_id=identity.stack_id)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_delete_bad_name(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'delete', True)
@ -2468,7 +2467,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant, body=body)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_list_resource_types(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'list_resource_types', True)
@ -2534,7 +2533,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_list_outputs(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'list_outputs', True)
@ -2732,7 +2731,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant,
type_name=type_name)
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
def test_generate_template(self, mock_enforce):
self._mock_enforce_setup(mock_enforce, 'generate_template', True)
@ -2766,7 +2765,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
type_name='TEST_TYPE')
self.assertIn('Template type is not supported: Invalid template '
'type "invalid", valid types are: cfn, hot.',
six.text_type(ex))
str(ex))
self.assertFalse(mock_call.called)
def test_generate_template_not_found(self, mock_enforce):
@ -2800,7 +2799,7 @@ class StackControllerTest(tools.ControllerTest, common.HeatTestCase):
req, tenant_id=self.tenant,
type_name='blah')
self.assertEqual(403, resp.status_int)
self.assertIn('403 Forbidden', six.text_type(resp))
self.assertIn('403 Forbidden', str(resp))
class StackSerializerTest(common.HeatTestCase):

View File

@ -12,7 +12,7 @@
# under the License.
import mock
from six.moves.urllib import parse as urlparse
from urllib import parse as urlparse
from heat.api.openstack.v1.views import views_common
from heat.tests import common

View File

@ -15,7 +15,6 @@ import mock
from oslo_config import cfg
from oslo_log import log
from oslo_messaging._drivers import common as rpc_common
import six
import webob.exc
from heat.common import wsgi
@ -94,7 +93,7 @@ class ControllerTest(object):
req = wsgi.Request(environ)
req.context = utils.dummy_context('api_test_user', self.tenant)
self.context = req.context
req.body = six.b(data)
req.body = data.encode('latin-1')
return req
def _post(self, path, data, content_type='application/json'):

View File

@ -18,7 +18,6 @@
import fixtures
import json
import mock
import six
import socket
import webob
@ -214,7 +213,7 @@ class ResourceTest(common.HeatTestCase):
None)
e = self.assertRaises(exception.HTTPExceptionDisguise,
resource, request)
self.assertEqual(message_es, six.text_type(e.exc))
self.assertEqual(message_es, str(e.exc))
class ResourceExceptionHandlingTest(common.HeatTestCase):
@ -250,7 +249,7 @@ class ResourceExceptionHandlingTest(common.HeatTestCase):
None)
e = self.assertRaises(self.exception_catch, resource, request)
e = e.exc if hasattr(e, 'exc') else e
self.assertNotIn(six.text_type(e), self.LOG.output)
self.assertNotIn(str(e), self.LOG.output)
class JSONRequestDeserializerTest(common.HeatTestCase):
@ -387,7 +386,7 @@ class JSONRequestDeserializerTest(common.HeatTestCase):
msg = ('Request limit exceeded: JSON body size '
'(%s bytes) exceeds maximum allowed size (%s bytes).' % (
len(body), cfg.CONF.max_json_body_size))
self.assertEqual(msg, six.text_type(error))
self.assertEqual(msg, str(error))
class GetSocketTestCase(common.HeatTestCase):

View File

@ -15,7 +15,6 @@ import json
import mock
from oslo_utils import timeutils
import six
from heat.common import exception
from heat.common import grouputils
@ -499,7 +498,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase):
mock_members = self.patchobject(grouputils, 'get_members')
members = []
output = []
for ip_ex in six.moves.range(1, 4):
for ip_ex in range(1, 4):
inst = mock.Mock()
inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex
output.append('2.1.3.%d' % ip_ex)
@ -543,7 +542,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase):
mock_members = self.patchobject(grouputils, 'get_members')
members = []
output = {}
for ip_ex in six.moves.range(1, 4):
for ip_ex in range(1, 4):
inst = mock.Mock()
inst.name = str(ip_ex)
inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex
@ -559,7 +558,7 @@ class HeatScalingGroupAttrFallbackTest(common.HeatTestCase):
self.group.nested = mock.Mock()
members = []
output = []
for ip_ex in six.moves.range(0, 2):
for ip_ex in range(0, 2):
inst = mock.Mock()
inst.name = 'ab'[ip_ex]
inst.FnGetAtt.return_value = '2.1.3.%d' % ip_ex
@ -644,7 +643,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
stack = utils.parse_stack(tmpl)
error = self.assertRaises(
exception.StackValidationFailed, stack.validate)
self.assertIn("foo", six.text_type(error))
self.assertIn("foo", str(error))
def test_parse_with_bad_pausetime_in_update_policy(self):
tmpl = template_format.parse(asg_tmpl_with_default_updt_policy())
@ -654,7 +653,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
error = self.assertRaises(
exception.StackValidationFailed, stack.validate)
self.assertIn("could not convert string to float",
six.text_type(error))
str(error))
class RollingUpdatePolicyDiffTest(common.HeatTestCase):
@ -736,7 +735,7 @@ class IncorrectUpdatePolicyTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Unknown Property AutoScalingRollingUpdate',
six.text_type(exc))
str(exc))
def test_with_update_policy_inst_group(self):
t = template_format.parse(inline_templates.as_heat_template)
@ -750,7 +749,7 @@ class IncorrectUpdatePolicyTest(common.HeatTestCase):
stack = utils.parse_stack(tmpl)
exc = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Unknown Property RollingUpdate', six.text_type(exc))
self.assertIn('Unknown Property RollingUpdate', str(exc))
class TestCooldownMixin(common.HeatTestCase):

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
from heat.common import exception
from heat.common import template_format
@ -61,7 +60,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
stack.validate)
self.assertIn('min_adjustment_step property should only '
'be specified for adjustment_type with '
'value percent_change_in_capacity.', six.text_type(ex))
'value percent_change_in_capacity.', str(ex))
def test_scaling_policy_bad_group(self):
t = template_format.parse(inline_templates.as_heat_template_bad_group)
@ -70,7 +69,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
ex = self.assertRaises(exception.ResourceFailure, up_policy.signal)
self.assertIn('Alarm my-policy could '
'not find scaling group', six.text_type(ex))
'not find scaling group', str(ex))
def test_scaling_policy_adjust_no_action(self):
t = template_format.parse(as_template)

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
from heat.common import exception
from heat.common import short_id
@ -111,7 +110,7 @@ class LaunchConfigurationTest(common.HeatTestCase):
rsrc.validate)
ex_msg = ('If without InstanceId, '
'ImageId and InstanceType are required.')
self.assertIn(ex_msg, six.text_type(e))
self.assertIn(ex_msg, str(e))
def test_lc_validate_without_InstanceId_and_InstanceType(self):
t = template_format.parse(inline_templates.as_template)
@ -126,7 +125,7 @@ class LaunchConfigurationTest(common.HeatTestCase):
rsrc.validate)
ex_msg = ('If without InstanceId, '
'ImageId and InstanceType are required.')
self.assertIn(ex_msg, six.text_type(e))
self.assertIn(ex_msg, str(e))
def test_launch_config_create_with_instanceid_not_found(self):
t = template_format.parse(inline_templates.as_template)
@ -148,7 +147,7 @@ class LaunchConfigurationTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate)
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
def test_validate_BlockDeviceMappings_without_Ebs_property(self):
t = template_format.parse(inline_templates.as_template)
@ -164,7 +163,7 @@ class LaunchConfigurationTest(common.HeatTestCase):
self.validate_launch_config, stack)
self.assertIn("Ebs is missing, this is required",
six.text_type(e))
str(e))
def test_validate_BlockDeviceMappings_without_SnapshotId_property(self):
t = template_format.parse(inline_templates.as_template)
@ -181,7 +180,7 @@ class LaunchConfigurationTest(common.HeatTestCase):
self.validate_launch_config, stack)
self.assertIn("SnapshotId is missing, this is required",
six.text_type(e))
str(e))
def test_validate_BlockDeviceMappings_without_DeviceName_property(self):
t = template_format.parse(inline_templates.as_template)
@ -201,4 +200,4 @@ class LaunchConfigurationTest(common.HeatTestCase):
'Property error: '
'Resources.LaunchConfig.Properties.BlockDeviceMappings[0]: '
'Property DeviceName not assigned')
self.assertIn(excepted_error, six.text_type(e))
self.assertIn(excepted_error, str(e))