summaryrefslogtreecommitdiff
path: root/heat/tests/test_parameters.py
diff options
context:
space:
mode:
authorThomas Herve <thomas.herve@enovance.com>2014-02-05 15:38:50 +0100
committerThomas Herve <thomas.herve@enovance.com>2014-03-26 09:57:45 +0100
commit573a15a7e1042f6f131d227ac8971fe8795d8c00 (patch)
treebcea9c24a7a979add6dd0ad4acc3e1618c502b98 /heat/tests/test_parameters.py
parentf18bb8b5af080d8f1114815bc2aac0ec2433146e (diff)
downloadheat-573a15a7e1042f6f131d227ac8971fe8795d8c00.tar.gz
Raise and catch a specific error during validation
This changes stack creation to return an error message instead of an exception when (some) validation fails. It doesn't convert all validation errors to keep the patch at a reasonable size. Change-Id: I6364bccacbc1d447a99ea61565c96fcc90bd21f9 Partial-Bug: #1276623
Diffstat (limited to 'heat/tests/test_parameters.py')
-rw-r--r--heat/tests/test_parameters.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/heat/tests/test_parameters.py b/heat/tests/test_parameters.py
index b2ae542a8..2882ebcac 100644
--- a/heat/tests/test_parameters.py
+++ b/heat/tests/test_parameters.py
@@ -123,7 +123,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'ConstraintDescription': 'wibble',
'MinLength': '4'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, 'foo')
self.assertIn('wibble', str(err))
@@ -131,7 +131,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'ConstraintDescription': 'wibble',
'MaxLength': '2'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, 'foo')
self.assertIn('wibble', str(err))
@@ -145,7 +145,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'ConstraintDescription': 'wibble',
'AllowedPattern': '[a-z]*'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, '1foo')
self.assertIn('wibble', str(err))
@@ -153,7 +153,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'ConstraintDescription': 'wibble',
'AllowedPattern': '[a-z]*'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, 'foo1')
self.assertIn('wibble', str(err))
@@ -167,7 +167,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'String',
'ConstraintDescription': 'wibble',
'AllowedValues': ['foo', 'bar', 'baz']}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, 'blarg')
self.assertIn('wibble', str(err))
@@ -189,7 +189,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Number',
'ConstraintDescription': 'wibble',
'MinValue': '4'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, '3')
self.assertIn('wibble', str(err))
@@ -197,7 +197,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Number',
'ConstraintDescription': 'wibble',
'MaxValue': '2'}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, '3')
self.assertIn('wibble', str(err))
@@ -211,7 +211,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Number',
'ConstraintDescription': 'wibble',
'AllowedValues': ['1', '3', '5']}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, '2')
self.assertIn('wibble', str(err))
@@ -231,8 +231,9 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'CommaDelimitedList',
'ConstraintDescription': 'wibble',
'AllowedValues': ['foo', 'bar', 'baz']}
- err = self.assertRaises(ValueError, self.new_parameter,
- 'p', schema, 'foo,baz,blarg')
+ err = self.assertRaises(exception.StackValidationFailed,
+ self.new_parameter, 'p', schema,
+ 'foo,baz,blarg')
self.assertIn('wibble', str(err))
def test_map_value(self):
@@ -275,7 +276,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Json',
'MinLength': 3}
val = {"foo": "bar", "items": [1, 2, 3]}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, val)
self.assertIn('out of range', str(err))
@@ -284,7 +285,7 @@ class ParameterTest(testtools.TestCase):
schema = {'Type': 'Json',
'MaxLength': 1}
val = {"foo": "bar", "items": [1, 2, 3]}
- err = self.assertRaises(ValueError,
+ err = self.assertRaises(exception.StackValidationFailed,
self.new_parameter, 'p', schema, val)
self.assertIn('out of range', str(err))