Skip to content
Snippets Groups Projects
Commit 133c16cc authored by Max Drexler's avatar Max Drexler
Browse files

testing xcd_lookup

parent 921e5100
1 merge request!2Switch to package setup
...@@ -42,7 +42,7 @@ else: ...@@ -42,7 +42,7 @@ else:
# Loaded using load_xcd_models() # Loaded using load_xcd_models()
_XCD_MODELS = None _XCD_MODELS = None
# default model_name, model_id when # default model_name, model_id
_XCD_MISSING = ("UNKWN", "UNKWN") _XCD_MISSING = ("UNKWN", "UNKWN")
...@@ -96,10 +96,11 @@ def load_xcd_models( ...@@ -96,10 +96,11 @@ def load_xcd_models(
) -> None: ) -> None:
"""Load the xcd models from the package.""" """Load the xcd models from the package."""
global _XCD_MODELS global _XCD_MODELS
# This MUST match name of xcd file in grib_processor.data if _XCD_MODELS is None:
data_path = resources.files(data) / "xcd_model_info.json" # This MUST match name of xcd file in grib_processor.data
with data_path.open("r") as xcd_data: data_path = resources.files(data) / "xcd_model_info.json"
_XCD_MODELS = json.load(xcd_data) with data_path.open("r") as xcd_data:
_XCD_MODELS = json.load(xcd_data)
for addtnl in addtnl_models: for addtnl in addtnl_models:
_XCD_MODELS.update(addtnl) _XCD_MODELS.update(addtnl)
......
from grib_processor.grib import xcd_lookup, load_xcd_models
def test_custom_loading():
"""Test that loading a custom xcd model works with xcd_lookup.
Note: This is a leaky test, the custom model will be in following tests.
"""
f_lat = 123
f_lon = 456
rows = 1
cols = 5
g_id = 6
m_name = "custom_name"
m_id = "custom_id"
c_model = {
str(f_lat): {str(f_lon): {str(rows): {str(cols): {str(g_id): [m_name, m_id]}}}}
}
load_xcd_models(c_model)
assert xcd_lookup(f_lat, f_lon, rows, cols, g_id) == (m_name, m_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment