From 0d3a1c42ac7ff62dc6ef169ca1726e90b4828e34 Mon Sep 17 00:00:00 2001 From: Colton Loftus <70598503+C-Loftus@users.noreply.github.com> Date: Mon, 26 Aug 2024 12:40:24 -0400 Subject: [PATCH] few edits to comments --- templates/usgs-location-oriented.j2 | 6 +++--- tests/runner.py | 12 ++---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/templates/usgs-location-oriented.j2 b/templates/usgs-location-oriented.j2 index d75e6ce..0a37f18 100644 --- a/templates/usgs-location-oriented.j2 +++ b/templates/usgs-location-oriented.j2 @@ -145,12 +145,12 @@ "measurementMethod": { - {# Can't say if it is a gaging station or another type since this is not provided in the raw jsonld#} - {# "url": "https://doi.org/10.3133/tm3A8" #} + {# Can't say if it is a gaging station or another type since this is not provided in the raw jsonld. + Also do not have enough info to link to a remote URL for the doi #} + {# "url": "https://doi.org/10.3133/tm3A8", #} "name": "{{ typeOfData }} Measurements", "publisher": "U.S. Geological Survey" - {# "url": "https://doi.org/10.3133/tm3A8" #} } }, {% if stream['observedArea'] is defined and stream['observedArea']['phenomenonTime'] %} diff --git a/tests/runner.py b/tests/runner.py index 5f3991a..bcae810 100644 --- a/tests/runner.py +++ b/tests/runner.py @@ -2,47 +2,39 @@ import json from jinja2 import Environment, FileSystemLoader -# Set up Jinja2 environment template_dir = 'templates' env = Environment(loader=FileSystemLoader(template_dir)) def apply_template_to_json(template_path, json_path): - # Load the template template = env.get_template(template_path) - # Load the JSON data with open(json_path) as json_file: data = json.load(json_file) + # pygeoapi templates use data as the key where all the properties are stored + # so we just rename the key data["data"] = data["properties"] - # Render the template with the JSON data result = template.render(data) return result -# Iterate over each template for template_filename in os.listdir(template_dir): if template_filename.endswith('.j2'): - # Determine the template name without the extension template_name = template_filename.replace('.j2', '') - # Set the corresponding test directory test_dir = os.path.abspath(os.path.join('tests', template_name)) if not os.path.isdir(test_dir): print(f"No test directory found for template {template_name}") continue - # Iterate over JSON files in the test directory for file_name in os.listdir(test_dir): if file_name.endswith('.json'): json_path = os.path.join(test_dir, file_name) template_path = template_filename - # Apply the template to the JSON file result = apply_template_to_json(template_path, json_path) - # Print the result print(f"Result for {file_name} using {template_filename}:") print(result) print("-" * 40)