Merge "Fix early resource property value validation"

This commit is contained in:
Jenkins 2014-07-17 09:24:55 +00:00 committed by Gerrit Code Review
commit 5e4b16d916
2 changed files with 17 additions and 1 deletions

View File

@ -278,7 +278,9 @@ class Property(object):
elif t == Schema.BOOLEAN:
_value = self._get_bool(value)
if validate:
# property value resolves to None if resource it depends on is not
# created. So, if value is None skip constraint validation.
if value is not None and validate:
self.schema.validate_constraints(_value, self.context)
return _value

View File

@ -1031,6 +1031,20 @@ class PropertiesTest(testtools.TestCase):
err = self.assertRaises(ValueError, props.get, 'foo')
self.assertEqual('foo resolution failed!', str(err))
def test_resolve_returns_none(self):
schema = {'foo': {'Type': 'String', "MinLength": "5"}}
def test_resolver(prop):
return None
props = properties.Properties(schema,
{'foo': 'get_attr: [db, value]'},
test_resolver)
try:
self.assertIsNone(props.validate())
except exception.StackValidationFailed:
self.fail("Constraints should not have been evaluated.")
def test_schema_from_params(self):
params_snippet = {
"DBUsername": {