Skip to content

Commit

Permalink
assure product is list. Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Trygve Aspenes committed Jan 7, 2025
1 parent 1fdeff4 commit eaf2820
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mapgen/modules/satellite_satpy_quicklook.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def _get_satpy_products(satpy_products, full_request, default_dataset):
ms_satpy_products = full_request['LAYER']
except KeyError:
pass
if not isinstance(ms_satpy_products, list):
ms_satpy_products = [ms_satpy_products]
return ms_satpy_products

def _get_mapfiles_path(regexp_pattern_module):
Expand Down
25 changes: 25 additions & 0 deletions tests/test_satellite_satpy_quicklook.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""Test arome arctic"""
import os
import logging
import datetime
import xarray as xr
import numpy as np
import pandas as pd
from unittest.mock import patch, MagicMock
from mapgen.modules.get_quicklook import get_quicklook

def test_get_satpy_products_is_list():
from mapgen.modules.satellite_satpy_quicklook import _get_satpy_products
assert isinstance(_get_satpy_products(None,{'layers': 'overview'}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'layers': ['overview']}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'LAYERS': 'overview'}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'LAYERS': ['overview']}, 'overview'), list)

assert isinstance(_get_satpy_products(None,{'layer': 'overview'}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'layer': ['overview']}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'LAYER': 'overview'}, 'overview'), list)
assert isinstance(_get_satpy_products(None,{'LAYER': ['overview']}, 'overview'), list)

assert isinstance(_get_satpy_products(None,{'NA': 'overview'}, 'overview'), list)

assert isinstance(_get_satpy_products('overview',{'NA': 'overview'}, 'overview'), list)

0 comments on commit eaf2820

Please sign in to comment.