Merge "Always convert AllowedValues to a list"

This commit is contained in:
Jenkins 2013-07-25 15:49:51 +00:00 committed by Gerrit Code Review
commit e6e0dc5b61
2 changed files with 5 additions and 4 deletions

View File

@ -87,7 +87,7 @@ class Parameter(object):
def _validate(self, value):
if VALUES in self.schema:
allowed = self.schema[VALUES]
allowed = list(self.schema[VALUES])
if value not in allowed:
message = '%s not in %s %s' % (value, VALUES, allowed)
raise ValueError(self._error_msg(message))
@ -253,7 +253,7 @@ class JsonParam(Parameter, collections.Mapping):
raise ValueError(self._error_msg(message))
# check valid keys
if VALUES in self.schema:
allowed = self.schema[VALUES]
allowed = list(self.schema[VALUES])
bad_keys = [k for k in self.parsed if k not in allowed]
if bad_keys:
message = ('keys %s are not in %s %s'

View File

@ -21,7 +21,8 @@ from heat.engine import parameters
SCHEMA_KEYS = (
REQUIRED, IMPLEMENTED, DEFAULT, TYPE, SCHEMA,
PATTERN, MIN_VALUE, MAX_VALUE, VALUES, MIN_LENGTH, MAX_LENGTH,
PATTERN, MIN_VALUE, MAX_VALUE, VALUES,
MIN_LENGTH, MAX_LENGTH,
) = (
'Required', 'Implemented', 'Default', 'Type', 'Schema',
'AllowedPattern', 'MinValue', 'MaxValue', 'AllowedValues',
@ -67,7 +68,7 @@ class Property(object):
def _check_allowed(self, value):
if VALUES in self.schema:
allowed = self.schema[VALUES]
allowed = list(self.schema[VALUES])
if value not in allowed:
raise ValueError('"%s" is not an allowed value %s' %
(value, str(allowed)))