Merge "Remove six and python 2.7 full support"

This commit is contained in:
Zuul 2020-05-03 05:36:50 +00:00 committed by Gerrit Code Review
commit 61195889e5
10 changed files with 49 additions and 59 deletions

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
from heat.common import exception
from heat.common import template_format
@ -124,4 +123,4 @@ class LBUtilsTest(common.HeatTestCase):
lbutils.reconfigure_loadbalancers,
[non_lb], id_list)
self.assertIn("Unsupported resource 'non_lb' in LoadBalancerNames",
six.text_type(error))
str(error))

View File

@ -16,7 +16,6 @@ import json
import mock
from oslo_utils import timeutils
import six
from heat.common import exception
from heat.common import grouputils
@ -77,7 +76,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
stack, 'WebServerGroup')
expected_msg = "The size of AutoScalingGroup can not be less than zero"
self.assertEqual(expected_msg, six.text_type(e))
self.assertEqual(expected_msg, str(e))
def test_invalid_max_size(self):
t = template_format.parse(as_template)
@ -96,7 +95,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
stack, 'WebServerGroup')
expected_msg = "MinSize can not be greater than MaxSize"
self.assertEqual(expected_msg, six.text_type(e))
self.assertEqual(expected_msg, str(e))
def test_invalid_desiredcapacity(self):
t = template_format.parse(as_template)
@ -114,7 +113,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
stack, 'WebServerGroup')
expected_msg = "DesiredCapacity must be between MinSize and MaxSize"
self.assertEqual(expected_msg, six.text_type(e))
self.assertEqual(expected_msg, str(e))
def test_invalid_desiredcapacity_zero(self):
t = template_format.parse(as_template)
@ -133,7 +132,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
stack, 'WebServerGroup')
expected_msg = "DesiredCapacity must be between MinSize and MaxSize"
self.assertEqual(expected_msg, six.text_type(e))
self.assertEqual(expected_msg, str(e))
def test_validate_without_InstanceId_and_LaunchConfigurationName(self):
t = template_format.parse(as_template)
@ -146,7 +145,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
"must be provided.")
exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate)
self.assertIn(error_msg, six.text_type(exc))
self.assertIn(error_msg, str(exc))
def test_validate_with_InstanceId_and_LaunchConfigurationName(self):
t = template_format.parse(as_template)
@ -158,7 +157,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
"must be provided.")
exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate)
self.assertIn(error_msg, six.text_type(exc))
self.assertIn(error_msg, str(exc))
def _stub_nova_server_get(self, not_found=False):
mock_server = mock.MagicMock()
@ -207,7 +206,7 @@ class TestAutoScalingGroupValidation(common.HeatTestCase):
"not be found.")
exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate)
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
class TestScalingGroupTags(common.HeatTestCase):
@ -640,7 +639,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
stack = utils.parse_stack(tmpl, params=inline_templates.as_params)
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())
@ -650,7 +649,7 @@ class RollingUpdatePolicyTest(common.HeatTestCase):
stack = utils.parse_stack(tmpl, params=inline_templates.as_params)
error = self.assertRaises(
exception.StackValidationFailed, stack.validate)
self.assertIn("Only ISO 8601 duration format", six.text_type(error))
self.assertIn("Only ISO 8601 duration format", str(error))
class RollingUpdatePolicyDiffTest(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
@ -63,7 +62,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
self.policy.validate)
self.assertIn('MinAdjustmentStep property should only '
'be specified for AdjustmentType with '
'value PercentChangeInCapacity.', six.text_type(ex))
'value PercentChangeInCapacity.', str(ex))
def test_scaling_policy_bad_group(self):
t = template_format.parse(inline_templates.as_template_bad_group)
@ -74,7 +73,7 @@ class TestAutoScalingPolicy(common.HeatTestCase):
ex = self.assertRaises(exception.ResourceFailure, up_policy.signal)
self.assertIn('Alarm WebServerScaleUpPolicy 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

@ -16,7 +16,6 @@ import copy
import mock
from neutronclient.common import exceptions as q_exceptions
from neutronclient.v2_0 import client as neutronclient
import six
from heat.common import exception
from heat.common import short_id
@ -454,7 +453,7 @@ class AllocTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
rsrc.validate)
self.assertIn(expected, six.text_type(exc))
self.assertIn(expected, str(exc))
def mock_show_network(self):
vpc_name = utils.PhysName('test_stack', 'the_vpc')
@ -672,7 +671,7 @@ class AllocTest(common.HeatTestCase):
rsrc.validate)
self.assertIn('At least one of the following properties '
'must be specified: InstanceId, NetworkInterfaceId',
six.text_type(exc))
str(exc))
def test_delete_association_successful_if_create_failed(self):
server = self.fc.servers.list()[0]

View File

@ -16,7 +16,6 @@ import uuid
import mock
from neutronclient.v2_0 import client as neutronclient
import six
from heat.common import exception
from heat.common import template_format
@ -245,7 +244,7 @@ class InstancesTest(common.HeatTestCase):
self.assertIn("WebServer.Properties.Volumes[0].VolumeId: "
"Error validating value '1234': The Volume "
"(1234) could not be found.",
six.text_type(exc))
str(exc))
mock_get_vol.assert_called_once_with('1234')
@ -285,7 +284,7 @@ class InstancesTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
instance.validate)
self.assertIn("Ebs is missing, this is required",
six.text_type(exc))
str(exc))
def test_validate_BlockDeviceMappings_without_SnapshotId_property(self):
stack_name = 'without_SnapshotId'
@ -305,7 +304,7 @@ class InstancesTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
instance.validate)
self.assertIn("SnapshotId is missing, this is required",
six.text_type(exc))
str(exc))
def test_validate_BlockDeviceMappings_without_DeviceName_property(self):
stack_name = 'without_DeviceName'
@ -330,7 +329,7 @@ class InstancesTest(common.HeatTestCase):
'Property error: '
'Resources.WebServer.Properties.BlockDeviceMappings[0]: '
'Property DeviceName not assigned')
self.assertIn(excepted_error, six.text_type(exc))
self.assertIn(excepted_error, str(exc))
def test_instance_create_with_image_id(self):
return_server = self.fc.servers.list()[1]
@ -397,7 +396,7 @@ class InstancesTest(common.HeatTestCase):
"StackValidationFailed: resources.instance_create_image_err: "
"Property error: WebServer.Properties.ImageId: "
"Error validating value 'Slackware': No image matching Slackware.",
six.text_type(error))
str(error))
def test_instance_create_duplicate_image_name_err(self):
stack_name = 'test_instance_create_image_name_err_stack'
@ -427,7 +426,7 @@ class InstancesTest(common.HeatTestCase):
"Property error: WebServer.Properties.ImageId: "
"Error validating value 'CentOS 5.2': No image unique match "
"found for CentOS 5.2.",
six.text_type(error))
str(error))
def test_instance_create_image_id_err(self):
stack_name = 'test_instance_create_image_id_err_stack'
@ -454,7 +453,7 @@ class InstancesTest(common.HeatTestCase):
"StackValidationFailed: resources.instance_create_image_err: "
"Property error: WebServer.Properties.ImageId: "
"Error validating value '1': No image matching 1.",
six.text_type(error))
str(error))
def test_handle_check(self):
(tmpl, stack) = self._setup_test_stack('test_instance_check_active')
@ -480,7 +479,7 @@ class InstancesTest(common.HeatTestCase):
return_value=False)
exc = self.assertRaises(exception.Error, instance.handle_check)
self.assertIn('foo', six.text_type(exc))
self.assertIn('foo', str(exc))
def test_instance_create_unexpected_status(self):
# checking via check_create_complete only so not to mock
@ -497,7 +496,7 @@ class InstancesTest(common.HeatTestCase):
instance.check_create_complete,
(creator, None))
self.assertEqual('Instance is not active - Unknown status BOGUS '
'due to "Unknown"', six.text_type(e))
'due to "Unknown"', str(e))
self.fc.servers.get.assert_called_once_with(instance.resource_id)
@ -521,7 +520,7 @@ class InstancesTest(common.HeatTestCase):
(creator, None))
self.assertEqual(
'Went to status ERROR due to "Message: NoValidHost, Code: 500"',
six.text_type(e))
str(e))
self.fc.servers.get.assert_called_once_with(instance.resource_id)
@ -541,7 +540,7 @@ class InstancesTest(common.HeatTestCase):
(creator, None))
self.assertEqual(
'Went to status ERROR due to "Message: Unknown, Code: Unknown"',
six.text_type(e))
str(e))
self.fc.servers.get.assert_called_once_with(instance.resource_id)
@ -761,7 +760,7 @@ class InstancesTest(common.HeatTestCase):
self.assertEqual(
"Error: resources.ud_type_f: "
"Resizing to '2' failed, status 'ERROR'",
six.text_type(error))
str(error))
self.assertEqual((instance.UPDATE, instance.FAILED), instance.state)
self.fc.servers.get.assert_called_with('1234')

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
from oslo_config import cfg
import swiftclient.client as sc
@ -255,7 +254,7 @@ class s3Test(common.HeatTestCase):
ex = self.assertRaises(exception.ResourceFailure, deleter)
self.assertIn("ResourceActionNotSupported: resources.test_resource: "
"The bucket you tried to delete is not empty",
six.text_type(ex))
str(ex))
self.mock_con.put_container.assert_called_once_with(
container_name,
{'X-Container-Write': 'test_tenant:test_username',
@ -278,7 +277,7 @@ class s3Test(common.HeatTestCase):
rsrc = self.create_resource(t, stack, 'S3Bucket')
deleter = scheduler.TaskRunner(rsrc.delete)
ex = self.assertRaises(exception.ResourceFailure, deleter)
self.assertIn("Conflict", six.text_type(ex))
self.assertIn("Conflict", str(ex))
self.mock_con.put_container.assert_called_once_with(
container_name,
{'X-Container-Write': 'test_tenant:test_username',

View File

@ -16,7 +16,6 @@ import copy
from cinderclient import exceptions as cinder_exp
import mock
from oslo_config import cfg
import six
from heat.common import exception
from heat.common import template_format
@ -105,7 +104,7 @@ class VolumeTest(vt_base.VolumeTestCase):
self._mock_delete_volume(fv)
ex = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.destroy))
self.assertIn("Volume in use", six.text_type(ex))
self.assertIn("Volume in use", str(ex))
self.cinder_fc.volumes.get.side_effect = [
vt_base.FakeVolume('available'), cinder_exp.NotFound('Not found')]
@ -176,7 +175,7 @@ class VolumeTest(vt_base.VolumeTestCase):
ex = self.assertRaises(exception.ResourceFailure,
self.create_volume, self.t, stack, 'DataVolume')
self.assertIn('Went to status error due to "Unknown"',
six.text_type(ex))
str(ex))
def test_volume_bad_tags(self):
stack_name = 'test_volume_bad_tags_stack'
@ -188,7 +187,7 @@ class VolumeTest(vt_base.VolumeTestCase):
self.create_volume, self.t, stack, 'DataVolume')
self.assertEqual("Property error: "
"Resources.DataVolume.Properties.Tags[0]: "
"Unknown Property Foo", six.text_type(ex))
"Unknown Property Foo", str(ex))
def test_volume_attachment_error(self):
stack_name = 'test_volume_attach_error_stack'
@ -208,7 +207,7 @@ class VolumeTest(vt_base.VolumeTestCase):
self.create_attachment,
self.t, stack, 'MountPoint')
self.assertIn("Volume attachment failed - Unknown status error",
six.text_type(ex))
str(ex))
self.validate_mock_create_server_volume_script()
def test_volume_attachment(self):
@ -383,7 +382,7 @@ class VolumeTest(vt_base.VolumeTestCase):
detach_task = scheduler.TaskRunner(rsrc.delete)
ex = self.assertRaises(exception.ResourceFailure, detach_task)
self.assertIn('Volume detachment failed - Unknown status error',
six.text_type(ex))
str(ex))
self.fc.volumes.delete_server_volume.assert_called_once_with(
u'WikiDatabase', 'vol-123')
@ -476,7 +475,7 @@ class VolumeTest(vt_base.VolumeTestCase):
"Update to properties "
"AvailabilityZone, Size, Tags of DataVolume "
"(AWS::EC2::Volume) is not supported",
six.text_type(ex))
str(ex))
self.assertEqual((rsrc.UPDATE, rsrc.FAILED), rsrc.state)
def test_volume_check(self):
@ -568,7 +567,7 @@ class VolumeTest(vt_base.VolumeTestCase):
ex = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(rsrc.destroy))
self.assertIn('Unknown status error', six.text_type(ex))
self.assertIn('Unknown status error', str(ex))
self.m_backups.create.assert_called_once_with(fv.id)
self.m_backups.get.assert_called_once_with(fb.id)
@ -597,7 +596,7 @@ class VolumeTest(vt_base.VolumeTestCase):
create = scheduler.TaskRunner(rsrc.create)
ex = self.assertRaises(exception.ResourceFailure, create)
self.assertIn('Went to status error due to "Unknown"',
six.text_type(ex))
str(ex))
self.cinder_fc.volumes.get.side_effect = [
fva,
@ -650,7 +649,7 @@ class VolumeTest(vt_base.VolumeTestCase):
ex = self.assertRaises(exception.ResourceFailure,
self.create_volume, self.t, stack, 'DataVolume')
self.assertIn('Went to status error due to "Unknown"',
six.text_type(ex))
str(ex))
cinder.CinderClientPlugin._create.assert_called_once_with()
self.m_restore.assert_called_once_with('backup-123')
@ -665,7 +664,7 @@ class VolumeTest(vt_base.VolumeTestCase):
self.t, stack, 'DataVolume')
self.assertEqual(
"Property error: Resources.DataVolume.Properties.Size: "
"0 is out of range (min: 1, max: None)", six.text_type(error))
"0 is out of range (min: 1, max: None)", str(error))
def test_volume_attachment_updates_not_supported(self):
self.patchobject(nova.NovaClientPlugin, 'get_server')
@ -694,7 +693,7 @@ class VolumeTest(vt_base.VolumeTestCase):
self.assertIn('NotSupported: resources.MountPoint: '
'Update to properties Device, InstanceId, '
'VolumeId of MountPoint (AWS::EC2::VolumeAttachment)',
six.text_type(ex))
str(ex))
self.assertEqual((rsrc.UPDATE, rsrc.FAILED), rsrc.state)
self.validate_mock_create_server_volume_script()

View File

@ -18,8 +18,7 @@ import uuid
import mock
from oslo_utils import timeutils
import six
from six.moves.urllib import parse
from urllib import parse
from heat.common import exception
from heat.common import identifier
@ -217,7 +216,7 @@ class WaitConditionTest(common.HeatTestCase):
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), rsrc.state)
wc_att = rsrc.FnGetAtt('Data')
self.assertEqual(six.text_type({}), wc_att)
self.assertEqual(str({}), wc_att)
handle = self.stack['WaitHandle']
self.assertEqual((rsrc.CREATE, rsrc.COMPLETE), handle.state)
@ -233,7 +232,7 @@ class WaitConditionTest(common.HeatTestCase):
'Status': 'SUCCESS', 'UniqueId': '456'}
ret = handle.handle_signal(test_metadata)
wc_att = rsrc.FnGetAtt('Data')
self.assertIsInstance(wc_att, six.string_types)
self.assertIsInstance(wc_att, str)
self.assertEqual({"123": "foo", "456": "dog"}, json.loads(wc_att))
self.assertEqual('status:SUCCESS reason:cat', ret)
self.assertEqual(1, self.m_gs.call_count)
@ -621,6 +620,6 @@ class WaitConditionUpdateTest(common.HeatTestCase):
ex = self.assertRaises(exception.ResourceFailure,
updater)
self.assertEqual("WaitConditionTimeout: resources.WaitForTheHandle: "
"0 of 5 received", six.text_type(ex))
"0 of 5 received", str(ex))
self.assertEqual(5, rsrc.properties['Count'])
self.assertEqual(2, m_gs.call_count)

View File

@ -25,7 +25,6 @@ from neutronclient.common import exceptions as neutron_exc
from openstack import exceptions
from oslo_config import cfg
from saharaclient.api import base as sahara_base
import six
from swiftclient import exceptions as swift_exc
from testtools import testcase
from troveclient import client as troveclient
@ -48,12 +47,12 @@ class ClientsTest(common.HeatTestCase):
cfg.CONF.set_override('cloud_backend', 'some.weird.object')
exc = self.assertRaises(exception.Invalid, clients.Clients, con)
self.assertIn('Invalid cloud_backend setting in heat.conf detected',
six.text_type(exc))
str(exc))
cfg.CONF.set_override('cloud_backend', 'heat.engine.clients.Clients')
exc = self.assertRaises(exception.Invalid, clients.Clients, con)
self.assertIn('Invalid cloud_backend setting in heat.conf detected',
six.text_type(exc))
str(exc))
def test_clients_get_heat_url(self):
con = mock.Mock()

View File

@ -25,7 +25,6 @@ from keystoneauth1 import token_endpoint as ks_token_endpoint
from keystoneclient.v3 import client as kc_v3
from keystoneclient.v3 import domains as kc_v3_domains
from oslo_config import cfg
import six
from heat.common import config
from heat.common import exception
@ -234,7 +233,7 @@ class KeystoneClientTest(common.HeatTestCase):
err = self.assertRaises(exception.Error,
heat_ks_client.create_stack_user,
'auser', password='password')
self.assertIn("Can't find role heat_stack_user", six.text_type(err))
self.assertIn("Can't find role heat_stack_user", str(err))
self.mock_ks_v3_client.roles.list.assert_called_once_with(
name='heat_stack_user')
self._validate_stub_auth()
@ -327,7 +326,7 @@ class KeystoneClientTest(common.HeatTestCase):
err = self.assertRaises(exception.Error,
heat_ks_client.create_stack_domain_user,
username='duser', project_id='aproject')
self.assertIn("Can't find role heat_stack_user", six.text_type(err))
self.assertIn("Can't find role heat_stack_user", str(err))
self._validate_stub_domain_admin_client()
self.mock_ks_v3_client.roles.list.assert_called_once_with(
name='heat_stack_user')
@ -643,7 +642,7 @@ class KeystoneClientTest(common.HeatTestCase):
heat_ks_client.create_trust_context)
expected = "Missing required credential: roles "
"{'role_names': ['heat_stack_owner']}"
self.assertIn(expected, six.text_type(exc))
self.assertIn(expected, str(exc))
self.m_load_auth.assert_called_with(
cfg.CONF, 'trustee', trust_id=None)
self.mock_ks_v3_client.trusts.create.assert_called_once_with(
@ -681,7 +680,7 @@ class KeystoneClientTest(common.HeatTestCase):
'"stack_user_domain_id" or "stack_user_domain_name" '
'without "stack_domain_admin" and '
'"stack_domain_admin_password"')
self.assertIn(exp_msg, six.text_type(err))
self.assertIn(exp_msg, str(err))
def test_trust_init(self):