Update schema_validation to use new import structure.

pull/167/head^2^2
Graham Welch 10 years ago
parent 94a9b3031e
commit 96c734e516

@ -108,7 +108,7 @@ def Validate(properties, schema_name, template_name, imports):
properties: dict, the properties to be validated
schema_name: name of the schema file to validate
template_name: name of the template whose properties are being validated
imports: the map of imported files names to file contents
imports: the map of imported files names to map containing path and content
Returns:
Dict containing the validated properties, with defaults filled in
@ -122,7 +122,7 @@ def Validate(properties, schema_name, template_name, imports):
raise ValidationErrors(schema_name, template_name,
["Could not find schema file '%s'." % schema_name])
raw_schema = imports[schema_name]
raw_schema = imports[schema_name]['content']
if properties is None:
properties = {}

@ -37,11 +37,20 @@ def RawValidate(raw_properties, schema_name, raw_schema):
{schema_name: raw_schema})
def ConvertImportMap(import_map):
"""Makes each import a map of {'content': value}."""
out = {}
for key in import_map:
out[key] = { 'content': import_map[key]}
return out
def ImportsRawValidate(raw_properties, schema_name, import_map):
"""Takes raw properties, calls validate and returns yaml properties."""
properties = yaml.safe_load(raw_properties)
return schema_validation.Validate(properties, schema_name, 'template.py',
import_map)
ConvertImportMap(import_map))
class SchemaValidationTest(unittest.TestCase):

Loading…
Cancel
Save