import collections
import re
+from heat.common import exception
+
SCHEMA_KEYS = (
REQUIRED, IMPLEMENTED, DEFAULT, TYPE, SCHEMA,
try:
self[key]
except ValueError as e:
- return str(e)
+ msg = "Property error : %s" % str(e)
+ raise exception.StackValidationFailed(message=msg)
# are there unimplemented Properties
if not prop.implemented() and key in self.data:
- return (self.error_prefix +
- '%s Property not implemented yet' % key)
+ msg = "Property %s not implemented yet" % key
+ raise exception.StackValidationFailed(message=msg)
for key in self.data:
if key not in self.props:
- return (self.error_prefix +
- 'Unknown Property "%s"' % key)
+ msg = "Unknown Property %s" % key
+ raise exception.StackValidationFailed(message=msg)
def __getitem__(self, key):
if key not in self:
self.stack.resolve_runtime_data,
self.name)
try:
- err = self.properties.validate()
- if err:
- return err
+ self.properties.validate()
self.state_set(self.CREATE_IN_PROGRESS)
if callable(getattr(self, 'handle_create', None)):
self.handle_create()
json_snippet.get('Properties', {}),
self.stack.resolve_runtime_data,
self.name)
- err = properties.validate()
- if err:
- raise ValueError(err)
+ properties.validate()
if callable(getattr(self, 'handle_update', None)):
result = self.handle_update(json_snippet)
except Exception as ex:
from nose.plugins.attrib import attr
from heat.engine import properties
+from heat.common import exception
@attr(tag=['unit', 'properties'])
def test_missing_required(self):
schema = {'foo': {'Type': 'String', 'Required': True}}
props = properties.Properties(schema, {})
- self.assertEqual(props.validate(), 'Property foo not assigned')
+ self.assertRaises(exception.StackValidationFailed, props.validate)
def test_missing_unimplemented(self):
schema = {'foo': {'Type': 'String', 'Implemented': False}}
def test_present_unimplemented(self):
schema = {'foo': {'Type': 'String', 'Implemented': False}}
props = properties.Properties(schema, {'foo': 'bar'})
- self.assertEqual(props.validate(), 'foo Property not implemented yet')
+ self.assertRaises(exception.StackValidationFailed, props.validate)
def test_missing(self):
schema = {'foo': {'Type': 'String'}}
def test_bad_data(self):
schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'foo': 42})
- self.assertEqual(props.validate(), 'foo Value must be a string')
+ self.assertRaises(exception.StackValidationFailed, props.validate)
def test_unknown_typo(self):
schema = {'foo': {'Type': 'String'}}
props = properties.Properties(schema, {'food': 42})
- self.assertNotEqual(props.validate(), None)
+ self.assertRaises(exception.StackValidationFailed, props.validate)
from nose.plugins.attrib import attr
from heat.tests.v1_1 import fakes
+from heat.common import exception
from heat.common import template_format
from heat.engine.resources import instance as instances
from heat.engine import service
self.m.ReplayAll()
volumeattach = stack.resources['MountPoint']
- self.assertTrue(volumeattach.validate())
+ self.assertRaises(exception.StackValidationFailed,
+ volumeattach.validate)
def test_validate_ref_valid(self):
t = template_format.parse(test_template_ref % 'WikiDatabase')