- with open(testcase_loc) as testcase_file:
- testcases = yaml.safe_load(testcase_file)
- blueprint = testcases['blueprint']
- for section in blueprint['sections']:
- print('## Section {}'.format(section))
- for testcase in blueprint[section]:
- run_testcase(testcase)
+ print('## Layer {}'.format(layer))
+ for testcase in blueprint[layer]:
+ testcase['layer'] = layer
+ run_testcase(testcase)
+
+
+def validate_blueprint(yaml_loc, layer):
+ """Parse yaml file and validates given layer. If no layer given all layers
+ validated
+ """
+ with open(yaml_loc) as yaml_file:
+ yamldoc = yaml.safe_load(yaml_file)
+ blueprint = yamldoc['blueprint']
+ if layer is None:
+ for each_layer in blueprint['layers']:
+ validate_layer(blueprint, each_layer)
+ else:
+ validate_layer(blueprint, layer)
+
+
+@click.command()
+@click.argument('blueprint')
+@click.option('--layer', '-l')
+def main(blueprint, layer):
+ """Takes blueprint name and optional layer. Validates inputs and derives
+ yaml location from blueprint name. Invokes validate on blue print.
+ """
+ yaml_loc = 'bluval/bluval-{}.yaml'.format(blueprint)
+ if layer is not None:
+ layer = layer.lower()
+ validate_blueprint(yaml_loc, layer)