Merge "Remove six and python 2.7 full support"

This commit is contained in:
Zuul 2020-05-03 05:58:29 +00:00 committed by Gerrit Code Review
commit 130151f547
10 changed files with 193 additions and 203 deletions

View File

@ -12,7 +12,6 @@
# under the License.
import mock
import six
from heat.common import grouputils
from heat.common import identifier
@ -50,7 +49,7 @@ class GroupUtilsTest(common.HeatTestCase):
group.nested.return_value = stack
# member list (sorted)
members = [r for r in six.itervalues(stack)]
members = [r for r in stack.values()]
expected = sorted(members, key=lambda r: (r.created_time, r.name))
actual = grouputils.get_members(group)
self.assertEqual(expected, actual)

View File

@ -25,7 +25,7 @@ class HackingTestCase(common.HeatTestCase):
"obj.items()"))))
self.assertEqual(0, len(list(checks.check_python3_no_iteritems(
"six.iteritems(obj)"))))
"obj.items()"))))
def test_dict_iterkeys(self):
self.assertEqual(1, len(list(checks.check_python3_no_iterkeys(
@ -35,7 +35,7 @@ class HackingTestCase(common.HeatTestCase):
"obj.keys()"))))
self.assertEqual(0, len(list(checks.check_python3_no_iterkeys(
"six.iterkeys(obj)"))))
"obj.keys()"))))
def test_dict_itervalues(self):
self.assertEqual(1, len(list(checks.check_python3_no_itervalues(
@ -45,4 +45,4 @@ class HackingTestCase(common.HeatTestCase):
"obj.values()"))))
self.assertEqual(0, len(list(checks.check_python3_no_itervalues(
"six.itervalues(obj)"))))
"obj.values()"))))

View File

@ -13,7 +13,6 @@
import copy
import mock
import six
from heat.common import exception
from heat.common import identifier
@ -244,7 +243,7 @@ class HOTemplateTest(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('Each resource must contain a type key.',
six.text_type(error))
str(error))
def test_translate_resources_bad_type(self):
"""Test translation of resources including invalid keyword."""
@ -269,7 +268,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"Type" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_translate_resources_bad_properties(self):
"""Test translation of resources including invalid keyword."""
@ -294,7 +293,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"Properties" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_translate_resources_resources_without_name(self):
hot_tpl = template_format.parse('''
@ -312,8 +311,8 @@ class HOTemplateTest(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"resources" must contain a map of resource maps. '
'Found a [%s] instead' % six.text_type,
six.text_type(error))
'Found a [%s] instead' % str,
str(error))
def test_translate_resources_bad_metadata(self):
"""Test translation of resources including invalid keyword."""
@ -339,7 +338,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertEqual('"Metadata" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_translate_resources_bad_depends_on(self):
"""Test translation of resources including invalid keyword."""
@ -364,7 +363,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"DependsOn" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_translate_resources_bad_deletion_policy(self):
"""Test translation of resources including invalid keyword."""
@ -389,7 +388,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"DeletionPolicy" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_translate_resources_bad_update_policy(self):
"""Test translation of resources including invalid keyword."""
@ -414,7 +413,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl.__getitem__, tmpl.RESOURCES)
self.assertEqual('"UpdatePolicy" is not a valid keyword '
'inside a resource definition',
six.text_type(err))
str(err))
def test_get_outputs_good(self):
"""Test get outputs."""
@ -445,7 +444,7 @@ class HOTemplateTest(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertEqual('Each output must contain a value key.',
six.text_type(error))
str(error))
def test_get_outputs_bad_without_name(self):
"""Test get outputs without name."""
@ -461,8 +460,8 @@ class HOTemplateTest(common.HeatTestCase):
error = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertEqual('"outputs" must contain a map of output maps. '
'Found a [%s] instead' % six.text_type,
six.text_type(error))
'Found a [%s] instead' % str,
str(error))
def test_get_outputs_bad_description(self):
"""Test get outputs with bad description name."""
@ -478,7 +477,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertIn('Description', six.text_type(err))
self.assertIn('Description', str(err))
def test_get_outputs_bad_value(self):
"""Test get outputs with bad value name."""
@ -494,7 +493,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_tpl)
err = self.assertRaises(exception.StackValidationFailed,
tmpl.__getitem__, tmpl.OUTPUTS)
self.assertIn('Value', six.text_type(err))
self.assertIn('Value', str(err))
def test_resource_group_list_join(self):
"""Test list_join on a ResourceGroup's inner attributes
@ -596,7 +595,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_tpl_empty)
ex = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn('"str_replace" params must be strings or numbers, '
'param jsonvar1 is not valid', six.text_type(ex))
'param jsonvar1 is not valid', str(ex))
def test_liberty_str_replace_map_param(self):
"""Test str_replace function with non-string map param."""
@ -617,7 +616,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_tpl_empty)
ex = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn('"str_replace" params must be strings or numbers, '
'param listvar1 is not valid', six.text_type(ex))
'param listvar1 is not valid', str(ex))
def test_liberty_str_replace_list_param(self):
"""Test str_replace function with non-string param."""
@ -751,7 +750,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_ocata_tpl_empty)
ex = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertEqual('The following params were not found in the '
'template: var3', six.text_type(ex))
'template: var3', str(ex))
snippet = {'str_replace_strict':
{'template': 'Template var1 string var2',
@ -760,7 +759,7 @@ class HOTemplateTest(common.HeatTestCase):
ex = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertEqual('The following params were not found in the '
'template: var0', six.text_type(ex))
'template: var0', str(ex))
# str_replace_vstrict has same behaviour
snippet = {'str_replace_vstrict':
@ -772,7 +771,7 @@ class HOTemplateTest(common.HeatTestCase):
tmpl = template.Template(hot_pike_tpl_empty)
ex = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertEqual('The following params were not found in the '
'template: longvarname,var0,var', six.text_type(ex))
'template: longvarname,var0,var', str(ex))
def test_str_replace_strict_empty_param_ok(self):
"""Test str_replace_strict function with empty params."""
@ -799,7 +798,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet['str_replace_vstrict']['params']['var2'] = val
ex = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('str_replace_vstrict has an undefined or empty '
'value for param var2', six.text_type(ex))
'value for param var2', str(ex))
def test_str_replace_invalid_param_keys(self):
"""Test str_replace function parameter keys.
@ -822,7 +821,7 @@ class HOTemplateTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
self.assertIn('"str_replace" syntax should be str_replace:\\n',
six.text_type(ex))
str(ex))
def test_str_replace_strict_invalid_param_keys(self):
"""Test str_replace function parameter keys.
@ -843,7 +842,7 @@ class HOTemplateTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
self.assertIn('"str_replace_strict" syntax should be '
'str_replace_strict:\\n', six.text_type(ex))
'str_replace_strict:\\n', str(ex))
def test_str_replace_invalid_param_types(self):
"""Test str_replace function parameter values.
@ -865,7 +864,7 @@ class HOTemplateTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
self.assertIn('str_replace: "str_replace" parameters must be a'
' mapping', six.text_type(ex))
' mapping', str(ex))
def test_str_replace_invalid_param_type_init(self):
"""Test str_replace function parameter values.
@ -879,7 +878,7 @@ class HOTemplateTest(common.HeatTestCase):
TypeError,
cfn_functions.Replace,
None, 'Fn::Replace', args)
self.assertIn('parameters must be a mapping', six.text_type(ex))
self.assertIn('parameters must be a mapping', str(ex))
def test_str_replace_ref_get_param(self):
"""Test str_replace referencing parameters."""
@ -938,7 +937,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet, tmpl, stack)
self.assertEqual(
'Argument to "get_file" must be a string',
six.text_type(notStrErr))
str(notStrErr))
def test_get_file_missing_files(self):
"""Test get_file function with no matching key in files section."""
@ -955,7 +954,7 @@ class HOTemplateTest(common.HeatTestCase):
self.assertEqual(
('No content found in the "files" section for '
'get_file path: file:///tmp/foo.yaml'),
six.text_type(missingErr))
str(missingErr))
def test_get_file_nested_does_not_resolve(self):
"""Test get_file function does not resolve nested calls."""
@ -999,7 +998,7 @@ class HOTemplateTest(common.HeatTestCase):
k_tmpl = template.Template(hot_kilo_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, k_tmpl)
self.assertEqual("Items to join must be strings not {'foo': 'json'}",
six.text_type(exc))
str(exc))
def test_join_object_type_fail(self):
not_serializable = object
@ -1007,10 +1006,10 @@ class HOTemplateTest(common.HeatTestCase):
l_tmpl = template.Template(hot_liberty_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, l_tmpl)
self.assertIn('Items to join must be string, map or list not',
six.text_type(exc))
str(exc))
k_tmpl = template.Template(hot_kilo_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, k_tmpl)
self.assertIn("Items to join must be strings", six.text_type(exc))
self.assertIn("Items to join must be strings", str(exc))
def test_join_json_fail(self):
not_serializable = object
@ -1018,9 +1017,9 @@ class HOTemplateTest(common.HeatTestCase):
l_tmpl = template.Template(hot_liberty_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, l_tmpl)
self.assertIn('Items to join must be string, map or list',
six.text_type(exc))
str(exc))
self.assertIn("failed json serialization",
six.text_type(exc))
str(exc))
def test_join_invalid(self):
snippet = {'list_join': 'bad'}
@ -1028,25 +1027,25 @@ class HOTemplateTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, l_tmpl)
self.assertIn('list_join: Incorrect arguments to "list_join"',
six.text_type(exc))
str(exc))
k_tmpl = template.Template(hot_kilo_tpl_empty)
exc1 = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, k_tmpl)
self.assertIn('list_join: Incorrect arguments to "list_join"',
six.text_type(exc1))
str(exc1))
def test_join_int_invalid(self):
snippet = {'list_join': 5}
l_tmpl = template.Template(hot_liberty_tpl_empty)
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, l_tmpl)
self.assertIn('list_join: Incorrect arguments', six.text_type(exc))
self.assertIn('list_join: Incorrect arguments', str(exc))
k_tmpl = template.Template(hot_kilo_tpl_empty)
exc1 = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, k_tmpl)
self.assertIn('list_join: Incorrect arguments', six.text_type(exc1))
self.assertIn('list_join: Incorrect arguments', str(exc1))
def test_join_invalid_value(self):
snippet = {'list_join': [',']}
@ -1054,19 +1053,19 @@ class HOTemplateTest(common.HeatTestCase):
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, l_tmpl)
self.assertIn('list_join: Incorrect arguments to "list_join"',
six.text_type(exc))
str(exc))
k_tmpl = template.Template(hot_kilo_tpl_empty)
exc1 = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, k_tmpl)
self.assertIn('list_join: Incorrect arguments to "list_join"',
six.text_type(exc1))
str(exc1))
def test_join_invalid_multiple(self):
snippet = {'list_join': [',', 'bad', ['foo']]}
tmpl = template.Template(hot_liberty_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn('must operate on a list', six.text_type(exc))
self.assertIn('must operate on a list', str(exc))
def test_merge(self):
snippet = {'map_merge': [{'f1': 'b1', 'f2': 'b2'}, {'f1': 'b2'}]}
@ -1086,7 +1085,7 @@ class HOTemplateTest(common.HeatTestCase):
snippet = {'map_merge': [{'f1': 'b1', 'f2': 'b2'}, ['f1', 'b2']]}
tmpl = template.Template(hot_mitaka_tpl_empty)
exc = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn('Incorrect arguments', six.text_type(exc))
self.assertIn('Incorrect arguments', str(exc))
def test_merge_containing_repeat(self):
snippet = {'map_merge': {'repeat': {'template': {'ROLE': 'ROLE'},
@ -1385,12 +1384,12 @@ class HOTemplateTest(common.HeatTestCase):
error_msg = ('equals: Arguments to "equals" must be '
'of the form: [value_1, value_2]')
self.assertIn(error_msg, six.text_type(exc))
self.assertIn(error_msg, str(exc))
snippet = {'equals': "invalid condition"}
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl)
self.assertIn(error_msg, six.text_type(exc))
self.assertIn(error_msg, str(exc))
def test_equals_with_non_supported_function(self):
@ -1400,7 +1399,7 @@ class HOTemplateTest(common.HeatTestCase):
{'get_attr': [None, 'att2']}]}
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve_condition, snippet, tmpl)
self.assertIn('"get_attr" is invalid', six.text_type(exc))
self.assertIn('"get_attr" is invalid', str(exc))
def test_if(self):
snippet = {'if': ['create_prod', 'value_if_true', 'value_if_false']}
@ -1513,7 +1512,7 @@ resources:
self.resolve, snippet, tmpl)
self.assertIn('Arguments to "if" must be of the form: '
'[condition_name, value_if_true, value_if_false]',
six.text_type(exc))
str(exc))
def test_if_condition_name_non_existing(self):
snippet = {'if': ['cd_not_existing', 'value_true', 'value_false']}
@ -1525,8 +1524,8 @@ resources:
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl, stack)
self.assertIn('Invalid condition "cd_not_existing"',
six.text_type(exc))
self.assertIn('if:', six.text_type(exc))
str(exc))
self.assertIn('if:', str(exc))
def _test_repeat(self, templ=hot_kilo_tpl_empty):
"""Test repeat function."""
@ -1701,7 +1700,7 @@ resources:
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
self.assertIn('"permutations" should be boolean type '
'for repeat function', six.text_type(exc))
'for repeat function', str(exc))
def test_repeat_bad_args(self):
"""Tests reporting error by repeat function.
@ -1757,7 +1756,7 @@ resources:
]
for snippet in invalid_snippets:
exc = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn('must be a list of strings', six.text_type(exc))
self.assertIn('must be a list of strings', str(exc))
def test_digest_incorrect_number_arguments(self):
tmpl = template.Template(hot_kilo_tpl_empty)
@ -1771,14 +1770,14 @@ resources:
for snippet in invalid_snippets:
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('usage: ["<algorithm>", "<value>"]',
six.text_type(exc))
str(exc))
def test_digest_invalid_algorithm(self):
tmpl = template.Template(hot_kilo_tpl_empty)
snippet = {'digest': ['invalid_algorithm', 'foobar']}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('Algorithm must be one of', six.text_type(exc))
self.assertIn('Algorithm must be one of', str(exc))
def test_str_split(self):
tmpl = template.Template(hot_liberty_tpl_empty)
@ -1802,28 +1801,28 @@ resources:
tmpl = template.Template(hot_liberty_tpl_empty)
snippet = {'str_split': [',', 'bar,baz', 'bad']}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('Incorrect index to \"str_split\"', six.text_type(exc))
self.assertIn('Incorrect index to \"str_split\"', str(exc))
def test_str_split_index_out_of_range(self):
tmpl = template.Template(hot_liberty_tpl_empty)
snippet = {'str_split': [',', 'bar,baz', '2']}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
expected = 'Incorrect index to \"str_split\" should be between 0 and 1'
self.assertEqual(expected, six.text_type(exc))
self.assertEqual(expected, str(exc))
def test_str_split_bad_novalue(self):
tmpl = template.Template(hot_liberty_tpl_empty)
snippet = {'str_split': [',']}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('Incorrect arguments to \"str_split\"',
six.text_type(exc))
str(exc))
def test_str_split_bad_empty(self):
tmpl = template.Template(hot_liberty_tpl_empty)
snippet = {'str_split': []}
exc = self.assertRaises(ValueError, self.resolve, snippet, tmpl)
self.assertIn('Incorrect arguments to \"str_split\"',
six.text_type(exc))
str(exc))
def test_str_split_none_string_to_split(self):
tmpl = template.Template(hot_liberty_tpl_empty)
@ -1857,11 +1856,11 @@ resources:
# Hot template test
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'parameters')
self.assertIn(err_str, six.text_type(keyError))
self.assertIn(err_str, str(keyError))
# CFN template test
keyError = self.assertRaises(KeyError, tmpl.__getitem__, 'Parameters')
self.assertIn(err_str, six.text_type(keyError))
self.assertIn(err_str, str(keyError))
def test_parameters_section_not_iterable(self):
"""Check parameters section is not returned using the template as iter.
@ -1964,7 +1963,7 @@ resources:
self.resolve,
snippet,
stack.t, stack)
self.assertIn(next(iter(snippet)), six.text_type(error))
self.assertIn(next(iter(snippet)), str(error))
def test_resource_facade_missing_deletion_policy(self):
snippet = {'resource_facade': 'deletion_policy'}
@ -2042,7 +2041,7 @@ resources:
empty = template.Template(copy.deepcopy(hot_tpl_empty))
stack = parser.Stack(utils.dummy_context(), 'test_stack', source)
for defn in six.itervalues(source.outputs(stack)):
for defn in source.outputs(stack).values():
empty.add_output(defn)
self.assertEqual(hot_tpl['outputs'], empty.t['outputs'])
@ -2377,7 +2376,7 @@ resources:
tmpl = template.Template(hot_pike_tpl_empty)
msg = 'Incorrect arguments'
exc = self.assertRaises(TypeError, self.resolve, snippet, tmpl)
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
def test_list_concat_with_dict_arg(self):
snippet = {'list_concat': [{'k1': 'v2'}, ['v3', 'v4']]}
@ -2409,7 +2408,7 @@ resources:
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
msg = 'Incorrect arguments to '
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
def test_contains_with_invalid_args_number(self):
snippet = {'contains': ['v1', ['v1', 'v2'], 'redundant']}
@ -2417,7 +2416,7 @@ resources:
exc = self.assertRaises(exception.StackValidationFailed,
self.resolve, snippet, tmpl)
msg = 'must be of the form: [value1, [value1, value2]]'
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
def test_contains_with_invalid_sequence(self):
snippet = {'contains': ['v1', {'key': 'value'}]}
@ -2425,7 +2424,7 @@ resources:
exc = self.assertRaises(TypeError,
self.resolve, snippet, tmpl)
msg = 'should be a sequence'
self.assertIn(msg, six.text_type(exc))
self.assertIn(msg, str(exc))
class HotStackTest(common.HeatTestCase):
@ -2855,7 +2854,7 @@ class StackGetAttrValidationTest(common.HeatTestCase):
try:
stack.validate()
except exception.StackValidationFailed as exc:
self.fail("Validation should have passed: %s" % six.text_type(exc))
self.fail("Validation should have passed: %s" % str(exc))
self.assertEqual([],
stack.resources['resource2'].properties['a_list'])
self.assertEqual({},
@ -2872,7 +2871,7 @@ class StackGetAttrValidationTest(common.HeatTestCase):
try:
stack.validate()
except exception.StackValidationFailed as exc:
self.fail("Validation should have passed: %s" % six.text_type(exc))
self.fail("Validation should have passed: %s" % str(exc))
self.assertEqual([],
stack.resources['resource2'].properties['a_list'])
self.assertEqual({},
@ -3023,19 +3022,19 @@ class HOTParamValidatorTest(common.HeatTestCase):
value = 'wp'
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(len_desc, six.text_type(err))
self.assertIn(len_desc, str(err))
value = 'abcdefghijklmnopq'
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(len_desc, six.text_type(err))
self.assertIn(len_desc, str(err))
value = 'abcdefgh1'
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(pattern_desc1, six.text_type(err))
self.assertIn(pattern_desc1, str(err))
value = 'Abcdefghi'
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(pattern_desc2, six.text_type(err))
self.assertIn(pattern_desc2, str(err))
value = 'abcdefghi'
self.assertTrue(v(value))
@ -3073,22 +3072,22 @@ class HOTParamValidatorTest(common.HeatTestCase):
value = 'wp'
err = self.assertRaises(exception.StackValidationFailed,
run_parameters, value)
self.assertIn(len_desc, six.text_type(err))
self.assertIn(len_desc, str(err))
value = 'abcdefghijklmnopq'
err = self.assertRaises(exception.StackValidationFailed,
run_parameters, value)
self.assertIn(len_desc, six.text_type(err))
self.assertIn(len_desc, str(err))
value = 'abcdefgh1'
err = self.assertRaises(exception.StackValidationFailed,
run_parameters, value)
self.assertIn(pattern_desc1, six.text_type(err))
self.assertIn(pattern_desc1, str(err))
value = 'Abcdefghi'
err = self.assertRaises(exception.StackValidationFailed,
run_parameters, value)
self.assertIn(pattern_desc2, six.text_type(err))
self.assertIn(pattern_desc2, str(err))
value = 'abcdefghi'
self.assertTrue(run_parameters(value))
@ -3118,11 +3117,11 @@ class HOTParamValidatorTest(common.HeatTestCase):
value = 29999
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(range_desc, six.text_type(err))
self.assertIn(range_desc, str(err))
value = 50001
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(range_desc, six.text_type(err))
self.assertIn(range_desc, str(err))
value = 30000
self.assertTrue(v(value))
@ -3161,11 +3160,11 @@ class HOTParamValidatorTest(common.HeatTestCase):
value = "1"
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertEqual(desc, six.text_type(err))
self.assertEqual(desc, str(err))
value = "2"
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertEqual(desc, six.text_type(err))
self.assertEqual(desc, str(err))
value = "0"
self.assertTrue(v(value))
@ -3198,7 +3197,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
param['db_port'])
err = self.assertRaises(exception.InvalidSchemaError,
schema.validate)
self.assertIn(range_desc, six.text_type(err))
self.assertIn(range_desc, str(err))
def test_validate_schema_wrong_key(self):
hot_tpl = template_format.parse('''
@ -3211,7 +3210,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual("Invalid key 'foo' for parameter (param1)",
six.text_type(error))
str(error))
def test_validate_schema_no_type(self):
hot_tpl = template_format.parse('''
@ -3224,7 +3223,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual("Missing parameter type for parameter: param1",
six.text_type(error))
str(error))
def test_validate_schema_unknown_type(self):
hot_tpl = template_format.parse('''
@ -3237,7 +3236,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid type (Unicode)", six.text_type(error))
"Invalid type (Unicode)", str(error))
def test_validate_schema_constraints(self):
hot_tpl = template_format.parse('''
@ -3254,7 +3253,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid key 'allowed_valus' for parameter constraints",
six.text_type(error))
str(error))
def test_validate_schema_constraints_not_list(self):
hot_tpl = template_format.parse('''
@ -3270,7 +3269,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid parameter constraints for parameter param1, "
"expected a list", six.text_type(error))
"expected a list", str(error))
def test_validate_schema_constraints_not_mapping(self):
hot_tpl = template_format.parse('''
@ -3286,7 +3285,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid parameter constraints, expected a mapping",
six.text_type(error))
str(error))
def test_validate_schema_empty_constraints(self):
hot_tpl = template_format.parse('''
@ -3301,7 +3300,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
error = self.assertRaises(
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual("No constraint expressed", six.text_type(error))
self.assertEqual("No constraint expressed", str(error))
def test_validate_schema_constraints_range_wrong_format(self):
hot_tpl = template_format.parse('''
@ -3318,7 +3317,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid range constraint, expected a mapping",
six.text_type(error))
str(error))
def test_validate_schema_constraints_range_invalid_key(self):
hot_tpl = template_format.parse('''
@ -3334,7 +3333,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid key 'foo' for range constraint", six.text_type(error))
"Invalid key 'foo' for range constraint", str(error))
def test_validate_schema_constraints_length_wrong_format(self):
hot_tpl = template_format.parse('''
@ -3351,7 +3350,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid length constraint, expected a mapping",
six.text_type(error))
str(error))
def test_validate_schema_constraints_length_invalid_key(self):
hot_tpl = template_format.parse('''
@ -3367,7 +3366,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"Invalid key 'foo' for length constraint", six.text_type(error))
"Invalid key 'foo' for length constraint", str(error))
def test_validate_schema_constraints_wrong_allowed_pattern(self):
hot_tpl = template_format.parse('''
@ -3383,7 +3382,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
exception.InvalidSchemaError, cfn_param.CfnParameters,
"stack_testit", template.Template(hot_tpl))
self.assertEqual(
"AllowedPattern must be a string", six.text_type(error))
"AllowedPattern must be a string", str(error))
def test_modulo_constraint(self):
modulo_desc = 'Value must be an odd number'
@ -3409,11 +3408,11 @@ class HOTParamValidatorTest(common.HeatTestCase):
value = 2
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(modulo_desc, six.text_type(err))
self.assertIn(modulo_desc, str(err))
value = 100
err = self.assertRaises(exception.StackValidationFailed, v, value)
self.assertIn(modulo_desc, six.text_type(err))
self.assertIn(modulo_desc, str(err))
value = 1
self.assertTrue(v(value))
@ -3442,7 +3441,7 @@ class HOTParamValidatorTest(common.HeatTestCase):
schema = hot_param.HOTParamSchema20170224.from_dict(
modulo_name, param[modulo_name])
err = self.assertRaises(exception.InvalidSchemaError, schema.validate)
self.assertIn(modulo_desc, six.text_type(err))
self.assertIn(modulo_desc, str(err))
class TestGetAttAllAttributes(common.HeatTestCase):
@ -3566,7 +3565,7 @@ class TestGetAttAllAttributes(common.HeatTestCase):
if self.raises is not None:
ex = self.assertRaises(self.raises,
self.resolve, self.snippet, tmpl, stack)
self.assertEqual(self.expected, six.text_type(ex))
self.assertEqual(self.expected, str(ex))
else:
self.assertEqual(self.expected,
self.resolve(self.snippet, tmpl, stack))

View File

@ -15,7 +15,6 @@
import mock
from oslo_config import cfg
from requests import exceptions
import six
import yaml
from heat.common import exception
@ -164,7 +163,7 @@ Resources:
res = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Recursion depth exceeds', six.text_type(res))
self.assertIn('Recursion depth exceeds', str(res))
calls = [mock.call('https://server.test/depth1.template'),
mock.call('https://server.test/depth2.template'),
@ -229,7 +228,7 @@ Resources:
tr.return_value = 2
res = self.assertRaises(exception.StackValidationFailed,
stack.validate)
self.assertIn('Recursion depth exceeds', six.text_type(res))
self.assertIn('Recursion depth exceeds', str(res))
expected_count = cfg.CONF.get('max_nested_stack_depth') + 1
self.assertEqual(expected_count, urlfetch.get.call_count)

View File

@ -14,7 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import six
import webob
from heat.common import noauth
@ -47,7 +46,7 @@ class FakeApp(object):
if env[k] != v:
raise AssertionError('%s != %s' % (env[k], v))
resp = webob.Response()
resp.body = six.b('SUCCESS')
resp.body = 'SUCCESS'.encode('latin-1')
return resp(env, start_response)

View File

@ -12,7 +12,6 @@
# under the License.
from oslo_serialization import jsonutils as json
import six
from heat.common import exception
from heat.common import identifier
@ -125,11 +124,11 @@ class ParameterTestCommon(common.HeatTestCase):
err = self.assertRaises(exception.InvalidSchemaError,
new_parameter, 'p', schema)
self.assertIn('AllowedValues constraint invalid for Json',
six.text_type(err))
str(err))
else:
err = self.assertRaises(exception.InvalidSchemaError,
new_parameter, 'p', schema)
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_description(self):
description = 'Description of the parameter'
@ -200,7 +199,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'MinLength': '4'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, 'foo')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_string_overflow(self):
schema = {'Type': 'String',
@ -208,7 +207,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'MaxLength': '2'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, 'foo')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_string_pattern_good(self):
schema = {'Type': 'String',
@ -222,7 +221,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'AllowedPattern': '[a-z]*'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, '1foo')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_string_pattern_bad_suffix(self):
schema = {'Type': 'String',
@ -230,7 +229,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'AllowedPattern': '[a-z]*'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, 'foo1')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_string_value_list_good(self):
schema = {'Type': 'String',
@ -249,7 +248,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'AllowedValues': ['foo', 'bar', 'baz']}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, 'blarg')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_number_int_good(self):
schema = {'Type': 'Number',
@ -278,7 +277,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'MinValue': '4'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, '3')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_number_high(self):
schema = {'Type': 'Number',
@ -286,19 +285,19 @@ class ParameterTestSpecific(common.HeatTestCase):
'MaxValue': '2'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, '3')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_number_bad(self):
schema = {'Type': 'Number'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, 'str')
self.assertIn('float', six.text_type(err))
self.assertIn('float', str(err))
def test_number_bad_type(self):
schema = {'Type': 'Number'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, ['foo'])
self.assertIn('int', six.text_type(err))
self.assertIn('int', str(err))
def test_number_value_list_good(self):
schema = {'Type': 'Number',
@ -312,7 +311,7 @@ class ParameterTestSpecific(common.HeatTestCase):
'AllowedValues': ['1', '3', '5']}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, '2')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_list_value_list_default_empty(self):
schema = {'Type': 'CommaDelimitedList', 'Default': ''}
@ -345,7 +344,7 @@ class ParameterTestSpecific(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema,
'foo,baz,blarg')
self.assertIn('wibble', six.text_type(err))
self.assertIn('wibble', str(err))
def test_list_validate_good(self):
schema = {'Type': 'CommaDelimitedList'}
@ -365,7 +364,7 @@ class ParameterTestSpecific(common.HeatTestCase):
p.user_value = val_s
err = self.assertRaises(exception.StackValidationFailed,
p.validate)
self.assertIn('Parameter \'p\' is invalid', six.text_type(err))
self.assertIn('Parameter \'p\' is invalid', str(err))
def test_map_value(self):
'''Happy path for value that's already a map.'''
@ -382,7 +381,7 @@ class ParameterTestSpecific(common.HeatTestCase):
val = {"foo": "bar", "not_json": len}
err = self.assertRaises(ValueError,
new_parameter, 'p', schema, val)
self.assertIn('Value must be valid JSON', six.text_type(err))
self.assertIn('Value must be valid JSON', str(err))
def test_map_value_parse(self):
'''Happy path for value that's a string.'''
@ -400,7 +399,7 @@ class ParameterTestSpecific(common.HeatTestCase):
val = "I am not a map"
err = self.assertRaises(ValueError,
new_parameter, 'p', schema, val)
self.assertIn('Value must be valid JSON', six.text_type(err))
self.assertIn('Value must be valid JSON', str(err))
def test_map_underrun(self):
'''Test map length under MIN_LEN.'''
@ -409,7 +408,7 @@ class ParameterTestSpecific(common.HeatTestCase):
val = {"foo": "bar", "items": [1, 2, 3]}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, val)
self.assertIn('out of range', six.text_type(err))
self.assertIn('out of range', str(err))
def test_map_overrun(self):
'''Test map length over MAX_LEN.'''
@ -418,7 +417,7 @@ class ParameterTestSpecific(common.HeatTestCase):
val = {"foo": "bar", "items": [1, 2, 3]}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'p', schema, val)
self.assertIn('out of range', six.text_type(err))
self.assertIn('out of range', str(err))
def test_json_list(self):
schema = {'Type': 'Json'}
@ -452,7 +451,7 @@ class ParameterTestSpecific(common.HeatTestCase):
p.user_value = val_s
err = self.assertRaises(exception.StackValidationFailed,
p.validate)
self.assertIn('Parameter \'p\' is invalid', six.text_type(err))
self.assertIn('Parameter \'p\' is invalid', str(err))
def test_bool_value_true(self):
schema = {'Type': 'Boolean'}
@ -470,7 +469,7 @@ class ParameterTestSpecific(common.HeatTestCase):
schema = {'Type': 'Boolean'}
err = self.assertRaises(exception.StackValidationFailed,
new_parameter, 'bo', schema, 'foo')
self.assertIn("Unrecognized value 'foo'", six.text_type(err))
self.assertIn("Unrecognized value 'foo'", str(err))
def test_missing_param_str(self):
'''Test missing user parameter.'''
@ -497,7 +496,7 @@ class ParameterTestSpecific(common.HeatTestCase):
new_parameter, 'testparam', schema, '234')
expected = ("Parameter 'testparam' is invalid: "
'"234" does not match pattern "[a-z]*"')
self.assertEqual(expected, six.text_type(err))
self.assertEqual(expected, str(err))
params_schema = json.loads('''{
@ -603,7 +602,7 @@ class ParametersTest(ParametersBase):
'None'),
'AWS::StackName': 'test_params'}
mapped_params = params.map(six.text_type)
mapped_params = params.map(str)
mapped_params['Uni'] = mapped_params['Uni'].encode('utf-8')
self.assertEqual(expected, mapped_params)
@ -694,7 +693,7 @@ class ParameterSchemaTest(common.HeatTestCase):
parameters.Schema.from_dict, 'param_name',
{"foo": "bar"})
self.assertEqual("Invalid key 'foo' for parameter (param_name)",
six.text_type(error))
str(error))
def test_validate_schema_no_type(self):
error = self.assertRaises(exception.InvalidSchemaError,
@ -702,4 +701,4 @@ class ParameterSchemaTest(common.HeatTestCase):
'broken',
{"Description": "Hi!"})
self.assertEqual("Missing parameter type for parameter: broken",
six.text_type(error))
str(error))

View File

@ -13,7 +13,6 @@
import mock
from oslo_serialization import jsonutils
import six
from heat.common import exception
from heat.engine import constraints
@ -142,9 +141,9 @@ class PropertySchemaTest(common.HeatTestCase):
def test_all_resource_schemata(self):
for resource_type in resources.global_env().get_types():
for schema in six.itervalues(getattr(resource_type,
'properties_schema',
{})):
for schema in getattr(resource_type,
'properties_schema',
{}).values():
properties.Schema.from_legacy(schema)
def test_from_legacy_idempotency(self):
@ -636,7 +635,7 @@ class PropertySchemaTest(common.HeatTestCase):
update = True
sub_schema = prop.schema
if sub_schema:
for sub_prop_key, sub_prop in six.iteritems(sub_schema):
for sub_prop_key, sub_prop in sub_schema.items():
if not update:
self.assertEqual(update, sub_prop.update_allowed,
"Mismatch in update policies: "
@ -652,11 +651,11 @@ class PropertySchemaTest(common.HeatTestCase):
check_update_policy(resource_type, sub_prop_key,
sub_prop, update)
for resource_type, resource_class in six.iteritems(all_resources):
for resource_type, resource_class in all_resources.items():
props_schemata = properties.schemata(
resource_class.properties_schema)
for prop_key, prop in six.iteritems(props_schemata):
for prop_key, prop in props_schemata.items():
check_update_policy(resource_type, prop_key, prop)
@ -808,7 +807,7 @@ class PropertyTest(common.HeatTestCase):
schema = {'Type': 'Integer'}
p = properties.Property(schema)
ex = self.assertRaises(TypeError, p.get_value, '3a')
self.assertEqual("Value '3a' is not an integer", six.text_type(ex))
self.assertEqual("Value '3a' is not an integer", str(ex))
def test_integer_low(self):
schema = {'Type': 'Integer',
@ -1005,7 +1004,7 @@ class PropertyTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
p.get_value, {'valid': 'fish'}, True)
self.assertEqual('Property error: valid: "fish" is not a '
'valid boolean', six.text_type(ex))
'valid boolean', str(ex))
def test_map_schema_missing_data(self):
map_schema = {'valid': {'Type': 'Boolean'}}
@ -1018,7 +1017,7 @@ class PropertyTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
p.get_value, {}, True)
self.assertEqual('Property error: Property valid not assigned',
six.text_type(ex))
str(ex))
def test_list_schema_good(self):
map_schema = {'valid': {'Type': 'Boolean'}}
@ -1037,7 +1036,7 @@ class PropertyTest(common.HeatTestCase):
p.get_value,
[{'valid': 'True'}, {'valid': 'fish'}], True)
self.assertEqual('Property error: [1].valid: "fish" is not '
'a valid boolean', six.text_type(ex))
'a valid boolean', str(ex))
def test_list_schema_int_good(self):
list_schema = {'Type': 'Integer'}
@ -1050,7 +1049,7 @@ class PropertyTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
p.get_value, [42, 'fish'], True)
self.assertEqual("Property error: [1]: Value 'fish' is not "
"an integer", six.text_type(ex))
"an integer", str(ex))
class PropertiesTest(common.HeatTestCase):
@ -1118,7 +1117,7 @@ class PropertiesTest(common.HeatTestCase):
ex = self.assertRaises(KeyError, self.props.get_user_value, 'foo')
# Note we have to use args here: https://bugs.python.org/issue2651
self.assertEqual('Invalid Property foo',
six.text_type(ex.args[0]))
str(ex.args[0]))
def test_bad_key(self):
self.assertEqual('wibble', self.props.get('foo', 'wibble'))
@ -1127,7 +1126,7 @@ class PropertiesTest(common.HeatTestCase):
ex = self.assertRaises(KeyError, self.props.__getitem__, 'foo')
# Note we have to use args here: https://bugs.python.org/issue2651
self.assertEqual('Invalid Property foo',
six.text_type(ex.args[0]))
str(ex.args[0]))
def test_none_string(self):
schema = {'foo': {'Type': 'String'}}
@ -1713,14 +1712,14 @@ class PropertiesValidationTest(common.HeatTestCase):
props = properties.Properties(schema, {'foo': ['foo', 'bar']})
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
self.assertIn('Property error: foo: Value must be a string',
six.text_type(ex))
str(ex))
def test_dict_instead_string(self):
schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'foo': {'foo': 'bar'}})
ex = self.assertRaises(exception.StackValidationFailed, props.validate)
self.assertIn('Property error: foo: Value must be a string',
six.text_type(ex))
str(ex))
def test_none_string(self):
schema = {'foo': {'Type': 'String'}}
@ -1887,7 +1886,7 @@ class PropertiesValidationTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
props.validate)
self.assertEqual('Property error: foo[0]: Unknown Property bar',
six.text_type(ex))
str(ex))
def test_nested_properties_schema_invalid_property_in_map(self):
child_schema = {'Key': {'Type': 'String',
@ -1906,7 +1905,7 @@ class PropertiesValidationTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
props.validate)
self.assertEqual('Property error: foo.boo: Unknown Property bar',
six.text_type(ex))
str(ex))
def test_more_nested_properties_schema_invalid_property_in_list(self):
nested_child_schema = {'Key': {'Type': 'String',
@ -1924,7 +1923,7 @@ class PropertiesValidationTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
props.validate)
self.assertEqual('Property error: foo[0].doo: Unknown Property bar',
six.text_type(ex))
str(ex))
def test_more_nested_properties_schema_invalid_property_in_map(self):
nested_child_schema = {'Key': {'Type': 'String',
@ -1942,7 +1941,7 @@ class PropertiesValidationTest(common.HeatTestCase):
ex = self.assertRaises(exception.StackValidationFailed,
props.validate)
self.assertEqual('Property error: foo.boo.doo: Unknown Property bar',
six.text_type(ex))
str(ex))
def test_schema_to_template_empty_schema(self):
schema = {}

View File

@ -11,7 +11,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import six
from heat.common import exception
from heat.engine import properties_group as pg
@ -86,7 +85,7 @@ class TestSchemaSimpleValidation(common.HeatTestCase):
if self.message is not None:
ex = self.assertRaises(exception.InvalidSchemaError,
pg.PropertiesGroup, self.schema)
self.assertEqual(self.message, six.text_type(ex))
self.assertEqual(self.message, str(ex))
else:
self.assertIsInstance(pg.PropertiesGroup(self.schema),
pg.PropertiesGroup)

View File

@ -17,7 +17,6 @@ import os
import uuid
import mock
import six
from heat.common import exception
from heat.common.i18n import _
@ -441,7 +440,7 @@ class ProviderTemplateTest(common.HeatTestCase):
temp_res.validate)
self.assertEqual("Property Foo type mismatch between facade "
"DummyResource (Map) and provider (String)",
six.text_type(ex))
str(ex))
def test_properties_list_with_none(self):
provider = {
@ -626,7 +625,7 @@ class ProviderTemplateTest(common.HeatTestCase):
ex = self.assertRaises(exception.NotFound, env.get_class,
'OS::ResourceType', 'fred')
self.assertIn('Could not fetch remote template "some_magic.yaml"',
six.text_type(ex))
str(ex))
def test_metadata_update_called(self):
provider = {
@ -892,7 +891,7 @@ class ProviderTemplateTest(common.HeatTestCase):
err = self.assertRaises(exception.StackValidationFailed,
temp_res.validate)
self.assertIn('Error parsing template http://heatr/bad_tmpl.yaml',
six.text_type(err))
str(err))
mock_get.assert_called_once_with(test_templ_name,
allowed_schemes=('http', 'https',))
@ -1002,8 +1001,8 @@ class TemplateResourceCrudTest(common.HeatTestCase):
def test_handle_delete(self):
self.res.rpc_client = mock.MagicMock()
self.res.id = 55
self.res.uuid = six.text_type(uuid.uuid4())
self.res.resource_id = six.text_type(uuid.uuid4())
self.res.uuid = str(uuid.uuid4())
self.res.resource_id = str(uuid.uuid4())
self.res.action = self.res.CREATE
self.res.nested = mock.MagicMock()
ident = identifier.HeatIdentifier(self.ctx.tenant_id,

View File

@ -22,7 +22,6 @@ import uuid
import mock
from oslo_config import cfg
import six
from heat.common import exception
from heat.common.i18n import _
@ -173,7 +172,7 @@ class ResourceTest(common.HeatTestCase):
resource.Resource, 'wrong/name',
snippet, self.stack)
self.assertEqual('Resource name may not contain "/"',
six.text_type(ex))
str(ex))
@mock.patch.object(translation, 'resolve_and_find')
@mock.patch.object(parser.Stack, 'db_resource_get')
@ -227,7 +226,7 @@ class ResourceTest(common.HeatTestCase):
resource.Resource, resource_name,
snippet, self.stack)
self.assertIn(_('Resource "%s" has no type') % resource_name,
six.text_type(ex))
str(ex))
def test_state_defaults(self):
tmpl = rsrc_defn.ResourceDefinition('test_res_def', 'Foo')
@ -247,7 +246,7 @@ class ResourceTest(common.HeatTestCase):
ex = self.assertRaises(exception.NotSupported,
res.signal)
self.assertEqual('Signal resource during %s is not '
'supported.' % action, six.text_type(ex))
'supported.' % action, str(ex))
ev.assert_called_with(
action, status,
'Cannot signal resource during %s' % action)
@ -391,7 +390,7 @@ class ResourceTest(common.HeatTestCase):
"(%(type)s) can not be found.") %
{'external_id': external_id,
'type': res.type()})
self.assertEqual(message, six.text_type(e))
self.assertEqual(message, str(e))
def test_updated_from_external(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource',
@ -406,7 +405,7 @@ class ResourceTest(common.HeatTestCase):
err = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(res.update, utmpl)
)
self.assertEqual(expected_err_msg, six.text_type(err))
self.assertEqual(expected_err_msg, str(err))
def test_state_set_invalid(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo')
@ -917,7 +916,7 @@ class ResourceTest(common.HeatTestCase):
res.update_template_diff_properties,
after_props, before_props)
self.assertIn("Update to properties Spam, Viking of",
six.text_type(ex))
str(ex))
def test_resource(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource', 'Foo',
@ -1014,7 +1013,7 @@ class ResourceTest(common.HeatTestCase):
'Property Foo not assigned')
create = scheduler.TaskRunner(res.create)
err = self.assertRaises(exception.ResourceFailure, create)
self.assertIn(estr, six.text_type(err))
self.assertIn(estr, str(err))
self.assertEqual((res.CREATE, res.FAILED), res.state)
def test_create_fail_prop_typo(self):
@ -1028,7 +1027,7 @@ class ResourceTest(common.HeatTestCase):
'Unknown Property Food')
create = scheduler.TaskRunner(res.create)
err = self.assertRaises(exception.ResourceFailure, create)
self.assertIn(estr, six.text_type(err))
self.assertIn(estr, str(err))
self.assertEqual((res.CREATE, res.FAILED), res.state)
def test_create_fail_metadata_parse_error(self):
@ -1132,7 +1131,7 @@ class ResourceTest(common.HeatTestCase):
'Went to status ERROR due to "just because"')
create = scheduler.TaskRunner(res.create)
err = self.assertRaises(exception.ResourceFailure, create)
self.assertEqual(estr, six.text_type(err))
self.assertEqual(estr, str(err))
self.assertEqual((res.CREATE, res.FAILED), res.state)
self.assertEqual(
1, generic_rsrc.ResourceWithProps.handle_create.call_count)
@ -1287,7 +1286,7 @@ class ResourceTest(common.HeatTestCase):
updater = scheduler.TaskRunner(res.update, utmpl)
ex = self.assertRaises(resource.UpdateReplace, updater)
self.assertEqual('The Resource test_resource requires replacement.',
six.text_type(ex))
str(ex))
generic_rsrc.ResourceWithProps.handle_update.assert_called_once_with(
utmpl, mock.ANY, prop_diff)
@ -1310,7 +1309,7 @@ class ResourceTest(common.HeatTestCase):
updater = scheduler.TaskRunner(res.update, utmpl)
ex = self.assertRaises(resource.UpdateReplace, updater)
self.assertEqual('The Resource Unknown requires replacement.',
six.text_type(ex))
str(ex))
generic_rsrc.ResourceWithProps.handle_update.assert_called_once_with(
utmpl, mock.ANY, prop_diff)
@ -1488,7 +1487,7 @@ class ResourceTest(common.HeatTestCase):
exc = self.assertRaises(exception.Error,
res._verify_check_conditions, checks)
exc_text = six.text_type(exc)
exc_text = str(exc)
self.assertNotIn("'foo2':", exc_text)
self.assertNotIn("'foo4':", exc_text)
self.assertIn("'foo1': expected 'bar1', got 'baz1'", exc_text)
@ -1525,9 +1524,9 @@ class ResourceTest(common.HeatTestCase):
for state in invalid_states:
res.state_set(*state)
suspend = scheduler.TaskRunner(res.suspend)
expected = 'State %s invalid for suspend' % six.text_type(state)
expected = 'State %s invalid for suspend' % str(state)
exc = self.assertRaises(exception.ResourceFailure, suspend)
self.assertIn(expected, six.text_type(exc))
self.assertIn(expected, str(exc))
def test_resume_fail_invalid_states(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource',
@ -1545,9 +1544,9 @@ class ResourceTest(common.HeatTestCase):
for state in invalid_states:
res.state_set(*state)
resume = scheduler.TaskRunner(res.resume)
expected = 'State %s invalid for resume' % six.text_type(state)
expected = 'State %s invalid for resume' % str(state)
exc = self.assertRaises(exception.ResourceFailure, resume)
self.assertIn(expected, six.text_type(exc))
self.assertIn(expected, str(exc))
def test_suspend_fail_exception(self):
tmpl = rsrc_defn.ResourceDefinition('test_resource',
@ -1870,8 +1869,7 @@ class ResourceTest(common.HeatTestCase):
prop.schema.value,
res_name)
else:
for nest_prop_name, nest_prop in six.iteritems(
prop.schema):
for nest_prop_name, nest_prop in prop.schema.items():
_validate_property_schema(nest_prop_name,
nest_prop,
res_name)
@ -1880,8 +1878,8 @@ class ResourceTest(common.HeatTestCase):
for res_type in resource_types:
res_class = env.get_class(res_type)
if hasattr(res_class, "properties_schema"):
for property_schema_name, property_schema in six.iteritems(
res_class.properties_schema):
for property_schema_name, property_schema in \
res_class.properties_schema.items():
_validate_property_schema(
property_schema_name, property_schema,
res_class.__name__)
@ -2131,7 +2129,7 @@ class ResourceTest(common.HeatTestCase):
{5, 3}, 'engine-007', self.dummy_timeout,
self.dummy_event)
exc = self.assertRaises(exception.ResourceFailure, tr)
self.assertIn('Resource ID was not provided', six.text_type(exc))
self.assertIn('Resource ID was not provided', str(exc))
@mock.patch.object(resource.Resource, 'update_template_diff_properties')
@mock.patch.object(resource.Resource, '_needs_update')
@ -2273,7 +2271,7 @@ class ResourceTest(common.HeatTestCase):
ex = self.assertRaises(exception.UpdateInProgress, tr)
msg = ("The resource %s is already being updated." %
res.name)
self.assertEqual(msg, six.text_type(ex))
self.assertEqual(msg, str(ex))
# ensure requirements are not updated for failed resource
rs = resource_objects.Resource.get_obj(self.stack.context, res.id)
self.assertEqual([2, 1], rs.requires)
@ -2487,7 +2485,7 @@ class ResourceTest(common.HeatTestCase):
ex = self.assertRaises(exception.UpdateInProgress, tr)
msg = ("The resource %s is already being updated." %
res.name)
self.assertEqual(msg, six.text_type(ex))
self.assertEqual(msg, str(ex))
@mock.patch.object(resource_objects.Resource, 'get_obj')
def test_update_replacement_data(self, mock_get_obj):
@ -2718,7 +2716,7 @@ class ResourceDeleteRetryTest(common.HeatTestCase):
exc = self.assertRaises(exception.ResourceFailure,
scheduler.TaskRunner(res.delete))
exc_text = six.text_type(exc)
exc_text = str(exc)
self.assertIn('Conflict', exc_text)
self.assertEqual(
self.num_retries + 1,
@ -3062,7 +3060,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
ex = self.assertRaises(exception.InvalidTemplateReference,
stack.validate)
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
def test_validate_value_fail(self):
tmpl = template.Template({
@ -3081,7 +3079,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
stack.validate)
self.assertIn("Property error: resources.bar.properties.FooInt: "
"Value 'notanint' is not an integer",
six.text_type(ex))
str(ex))
# You can turn off value validation via strict_validate
stack_novalidate = parser.Stack(utils.dummy_context(), 'test', tmpl,
@ -3242,7 +3240,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
ex = self.assertRaises(exception.InvalidTemplateReference,
getattr, stack, 'dependencies')
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
def test_hot_getatt_fail(self):
tmpl = template.Template({
@ -3260,7 +3258,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
ex = self.assertRaises(exception.InvalidTemplateReference,
getattr, stack, 'dependencies')
self.assertIn('"baz" (in bar.Properties.Foo)', six.text_type(ex))
self.assertIn('"baz" (in bar.Properties.Foo)', str(ex))
def test_getatt_fail_nested_deep(self):
tmpl = template.Template({
@ -3284,7 +3282,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
ex = self.assertRaises(exception.InvalidTemplateReference,
getattr, stack, 'dependencies')
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])',
six.text_type(ex))
str(ex))
def test_hot_getatt_fail_nested_deep(self):
tmpl = template.Template({
@ -3308,7 +3306,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
ex = self.assertRaises(exception.InvalidTemplateReference,
getattr, stack, 'dependencies')
self.assertIn('"baz" (in bar.Properties.Foo.Fn::Join[1][3])',
six.text_type(ex))
str(ex))
def test_dependson(self):
tmpl = template.Template({
@ -3363,7 +3361,7 @@ class ResourceDependenciesTest(common.HeatTestCase):
stack = parser.Stack(utils.dummy_context(), 'test', tmpl)
ex = self.assertRaises(exception.InvalidTemplateReference,
getattr, stack, 'dependencies')
self.assertIn('"wibble" (in foo)', six.text_type(ex))
self.assertIn('"wibble" (in foo)', str(ex))
class MetadataTest(common.HeatTestCase):
@ -3880,7 +3878,7 @@ class ResourceAvailabilityTest(common.HeatTestCase):
'type UnavailableResourceType, reason: '
'Service endpoint not in service catalog.')
self.assertEqual(msg,
six.text_type(ex),
str(ex),
'invalid exception message')
# Make sure is_service_available is called on the right class
@ -3916,7 +3914,7 @@ class ResourceAvailabilityTest(common.HeatTestCase):
'type UnavailableResourceType, reason: '
'Authorization failed.')
self.assertEqual(msg,
six.text_type(ex),
str(ex),
'invalid exception message')
# Make sure is_service_available is called on the right class
@ -3999,7 +3997,7 @@ class ResourceAvailabilityTest(common.HeatTestCase):
with mock.patch.object(res, '_default_client_plugin',
return_value=client_plugin):
ex = self.assertRaises(exception.Error, res.handle_delete)
self.assertEqual('boom!', six.text_type(ex))
self.assertEqual('boom!', str(ex))
delete.assert_called_once_with('12345')
def test_handle_delete_no_entity(self):
@ -4129,7 +4127,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
'FooInt': 2})
res = generic_rsrc.ResourceWithProps('test_resource',
tmpl, self.stack)
for prop in six.itervalues(res.properties.props):
for prop in res.properties.props.values():
prop.schema.update_allowed = True
res.update_allowed_properties = ('Foo', 'FooInt',)
@ -4145,7 +4143,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
"""
res.update_allowed_properties = []
res.update_allowed_set = []
for prop in six.itervalues(res.properties.props):
for prop in res.properties.props.values():
prop.schema.update_allowed = False
def test_update_resource_live_state(self):
@ -4189,7 +4187,7 @@ class TestLiveStateUpdate(common.HeatTestCase):
ex = self.assertRaises(exception.EntityNotFound,
res.get_live_resource_data)
self.assertEqual('The Resource (test_resource) could not be found.',
six.text_type(ex))
str(ex))
self._clean_tests_after_resource_live_state(res)
def test_parse_live_resource_data(self):
@ -4292,7 +4290,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.assertEqual('ResourceActionRestricted: resources.bar: '
'update is restricted for resource.',
six.text_type(error))
str(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
@ -4319,7 +4317,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
scheduler.TaskRunner(res.update, snippet))
self.assertEqual('ResourceActionRestricted: resources.bar: '
'replace is restricted for resource.',
six.text_type(error))
str(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
@ -4366,7 +4364,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
props)
error = self.assertRaises(resource.UpdateReplace,
scheduler.TaskRunner(res.update, snippet))
self.assertIn('requires replacement', six.text_type(error))
self.assertIn('requires replacement', str(error))
self.assertEqual(1, prep_replace.call_count)
ev.assert_not_called()
@ -4396,7 +4394,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
eventlet.event.Event()))
self.assertEqual('ResourceActionRestricted: resources.bar: '
'replace is restricted for resource.',
six.text_type(error))
str(error))
self.assertEqual('UPDATE', error.action)
self.assertEqual((res.CREATE, res.COMPLETE), res.state)
ev.assert_called_with(res.UPDATE, res.FAILED,
@ -4426,7 +4424,7 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase):
self.dummy_timeout,
self.new_stack,
eventlet.event.Event()))
self.assertIn('requires replacement', six.text_type(error))
self.assertIn('requires replacement', str(error))
ev.assert_not_called()
@ -4436,8 +4434,8 @@ class TestResourceMapping(common.HeatTestCase):
self.assertTrue(callable(func))
res = func()
self.assertIsInstance(res, collections.Mapping)
for r_type, r_class in six.iteritems(res):
self.assertIsInstance(r_type, six.string_types)
for r_type, r_class in res.items():
self.assertIsInstance(r_type, str)
type_elements = r_type.split('::')
# type has fixed format
# Platform type::Service/Type::Optional Sub-sections::Name
@ -4445,11 +4443,11 @@ class TestResourceMapping(common.HeatTestCase):
# type should be OS or AWS
self.assertIn(type_elements[0], ('AWS', 'OS'))
# check that value is a class object
self.assertIsInstance(r_class, six.class_types)
self.assertIsInstance(r_class, type)
# check that class is subclass of Resource base class
self.assertTrue(issubclass(r_class, resource.Resource))
# check that mentioned class is presented in the same module
self.assertTrue(hasattr(module, six.text_type(r_class.__name__)))
self.assertTrue(hasattr(module, str(r_class.__name__)))
return len(res)
def test_resource_mappings(self):