Fix schema-to-template for empty schema

if schema is {}, the
schema_to_parameters_and_properties(schema)
function shouldn't get an error, and return
{}, {} for parameters and properties

Closes-Bug: #1341985

Change-Id: Ic206ba64811bf43080a9deebb7c3b4c19134c43d
This commit is contained in:
FeihuJiang 2014-07-17 02:48:19 +00:00
parent b6304d4f8d
commit 09ebba154a
2 changed files with 11 additions and 0 deletions

View File

@ -447,6 +447,9 @@ class Properties(collections.Mapping):
return (name, param_def), (name, prop_def)
if not schema:
return {}, {}
param_prop_defs = [param_prop_def_items(n, s)
for n, s in schemata(schema).iteritems()
if s.implemented]

View File

@ -1662,3 +1662,11 @@ class PropertiesValidationTest(testtools.TestCase):
self.assertEqual('Property error : foo Property error : foo: boo '
'Property error : boo: doo Unknown Property bar',
str(ex))
def test_schema_to_template_empty_schema(self):
schema = {}
(parameters, props) = \
properties.Properties.schema_to_parameters_and_properties(schema)
self.assertEqual({}, parameters)
self.assertEqual({}, props)