summaryrefslogtreecommitdiff
path: root/heat/tests/test_parameters.py
diff options
context:
space:
mode:
authorHervé Beraud <hberaud@redhat.com>2019-11-20 19:37:27 +0100
committerHervé Beraud <hberaud@redhat.com>2020-04-23 14:49:12 +0200
commitd7d3dcbb505dff18dcfc964dbd5fca63085267cf (patch)
tree448e8dba7bda0431d32c280a15e813d320ade0a1 /heat/tests/test_parameters.py
parentea89a2a08c1293ffd99c2e7b198a7b0e6842b174 (diff)
downloadheat-d7d3dcbb505dff18dcfc964dbd5fca63085267cf.tar.gz
Remove six and python 2.7 full support
Six is in use to help us to keep support for python 2.7. Since the ussuri cycle we decide to remove the python 2.7 support so we can go ahead and also remove six usage from the python code. Review process and help ----------------------- Removing six introduce a lot of changes and an huge amount of modified files To simplify reviews we decided to split changes into several patches to avoid painful reviews and avoid mistakes. To review this patch you can use the six documentation [1] to obtain help and understand choices. Additional informations ----------------------- Changes related to 'six.b(data)' [2] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ six.b [2] encode the given datas in latin-1 in python3 so I did the same things in this patch. Latin-1 is equal to iso-8859-1 [3]. This encoding is the default encoding [4] of certain descriptive HTTP headers. I suggest to keep latin-1 for the moment and to move to another encoding in a follow-up patch if needed to move to most powerful encoding (utf8). HTML4 support utf8 charset and utf8 is the default charset for HTML5 [5]. Note that this commit message is autogenerated and not necesserly contains changes related to 'six.b' [1] https://six.readthedocs.io/ [2] https://six.readthedocs.io/#six.b [3] https://docs.python.org/3/library/codecs.html#standard-encodings [4] https://www.w3schools.com/charsets/ref_html_8859.asp [5] https://www.w3schools.com/html/html_charset.asp Patch 26 of a serie of 28 patches Change-Id: I861e30278e66b680cd64ef659ff889414d4e55fb
Diffstat (limited to 'heat/tests/test_parameters.py')
-rw-r--r--heat/tests/test_parameters.py49
1 files changed, 24 insertions, 25 deletions
diff --git a/heat/tests/test_parameters.py b/heat/tests/test_parameters.py
index f438c37fb..66218cf6a 100644
--- a/heat/tests/test_parameters.py
+++ b/heat/tests/test_parameters.py
@@ -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))