- 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(str(yaml_loc)) as yaml_file:
+ yamldoc = yaml.safe_load(yaml_file)
+ blueprint = yamldoc['blueprint']
+ validate_layer(blueprint, layer)
+
+
+def write_test_info(layer):
+ """writes testing info to test_info.yaml
+ """
+ data = dict(
+ test_info=dict(
+ layer=layer,
+ optional=_OPTIONAL_ALSO,
+ )
+ )
+
+ with open('/opt/akraino/results/test_info.yaml', 'w') as outfile:
+ yaml.dump(data, outfile, default_flow_style=False)
+
+
+@click.command()
+@click.argument('blueprint')
+@click.option('--layer', '-l')
+@click.option('--optional_also', '-o', is_flag=True)
+def main(blueprint, layer, optional_also):
+ """Takes blueprint name and optional layer. Validates inputs and derives
+ yaml location from blueprint name. Invokes validate on blue print.
+ """
+ global _OPTIONAL_ALSO # pylint: disable=global-statement
+ mypath = Path(__file__).absolute()
+ yaml_loc = mypath.parents[0].joinpath('bluval-{}.yaml'.format(blueprint))
+ if layer is not None:
+ layer = layer.lower()
+ if optional_also:
+ _OPTIONAL_ALSO = True
+ print("_OPTIONAL_ALSO {}".format(_OPTIONAL_ALSO))
+
+ try:
+ write_test_info(layer)
+ validate_blueprint(yaml_loc, layer)
+ except ShowStopperError as err:
+ print('ShowStopperError:', err)
+ except BluvalError as err:
+ print('Unexpected BluvalError', err)
+ raise
+ except:
+ print("Exception in user code:")
+ print("-"*60)
+ traceback.print_exc(file=sys.stdout)
+ print("-"*60)
+ raise