in scripts/dashboard/validate_dashboards_format.py [0:0]
def check_json_in_metadata(directory, path_map):
'''Make following assertions about json template files:
* Template file name appears in metadata.yaml file
* Template display name matches corresponding id in metadata.yaml file
note: this function mutates the path_map dictionary'''
for json_file in path_map[directory]['json_files']:
json_path = os.path.join('.', 'dashboards', directory, json_file)
dash_dict = get_sample_dashboards_json(json_path)
json_id = json_file.split('.')[0]
if not json_id in path_map[directory]['metadata']:
raise JsonInMetadataMisMatchError("{} does not have a matching id in the metadata file".format(json_file))
if not dash_dict['displayName'] == path_map[directory]['metadata'][json_id]:
raise JsonInMetadataMisMatchError("{} does not have a matching display_name in the metadata file".format(json_file))