Remove the Property.schema_from_param() method

This is now unused.

Change-Id: I5da20effe72a791d6dd8e9cc99ec9e43dea2da07
This commit is contained in:
Zane Bitter 2013-08-19 20:51:45 +02:00
parent 5769f8f31c
commit 6b8c2a15e8
2 changed files with 0 additions and 58 deletions

View File

@ -475,13 +475,6 @@ class AllowedPattern(Constraint):
class Property(object):
__param_type_map = {
parameters.STRING: STRING,
parameters.NUMBER: NUMBER,
parameters.COMMA_DELIMITED_LIST: LIST,
parameters.JSON: MAP
}
def __init__(self, schema, name=None):
self.schema = Schema.from_legacy(schema)
self.name = name
@ -508,37 +501,6 @@ class Property(object):
except ValueError:
return float(value)
@staticmethod
def schema_from_param(param):
"""
Convert the param specification to a property schema definition
:param param: parameter definition
:return: a property schema definition for param
"""
if parameters.TYPE not in param:
raise ValueError("Parameter does not define a type for conversion")
ret = {
TYPE: Property.__param_type_map.get(param.get(parameters.TYPE))
}
if parameters.DEFAULT in param:
ret.update({DEFAULT: param[parameters.DEFAULT]})
else:
ret.update({REQUIRED: "true"})
if parameters.ALLOWED_VALUES in param:
ret.update({ALLOWED_VALUES: param[parameters.ALLOWED_VALUES]})
if parameters.ALLOWED_PATTERN in param:
ret.update({ALLOWED_PATTERN: param[parameters.ALLOWED_PATTERN]})
if parameters.MAX_LENGTH in param:
ret.update({MAX_LENGTH: param[parameters.MAX_LENGTH]})
if parameters.MIN_LENGTH in param:
ret.update({MIN_LENGTH: param[parameters.MIN_LENGTH]})
if parameters.MAX_VALUE in param:
ret.update({MAX_VALUE: param[parameters.MAX_VALUE]})
if parameters.MIN_VALUE in param:
ret.update({MIN_VALUE: param[parameters.MIN_VALUE]})
return ret
def _validate_integer(self, value):
if value is None:
value = self.has_default() and self.default() or 0

View File

@ -942,26 +942,6 @@ class PropertyTest(testtools.TestCase):
p = properties.Property({'Type': 'List', 'Schema': list_schema})
self.assertRaises(TypeError, p.validate_data, [42, 'fish'])
def test_schema_from_param(self):
param = {
"Description": "WebServer EC2 instance type",
"Type": "String",
"Default": "m1.large",
"AllowedValues": ["t1.micro", "m1.small", "m1.large", "m1.xlarge",
"m2.xlarge", "m2.2xlarge", "m2.4xlarge",
"c1.medium", "c1.xlarge", "cc1.4xlarge"],
"ConstraintDescription": "must be a valid EC2 instance type."
}
expected = {
'Default': 'm1.large',
'Type': 'String',
'AllowedValues': ['t1.micro', 'm1.small', 'm1.large', 'm1.xlarge',
'm2.xlarge', 'm2.2xlarge', 'm2.4xlarge',
'c1.medium', 'c1.xlarge', 'cc1.4xlarge']
}
self.assertEqual(expected,
properties.Property.schema_from_param(param))
class PropertiesTest(testtools.TestCase):
def setUp(self):