Skip to content

Commit

Permalink
added parse_inputs test
Browse files Browse the repository at this point in the history
  • Loading branch information
cehbrecht committed Sep 14, 2021
1 parent 9fb131a commit 96551d5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
42 changes: 41 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
import pytest

from rook.utils.input_utils import resolve_to_file_paths
from pywps.app import WPSRequest

from rook.utils.input_utils import resolve_to_file_paths, parse_wps_input
from rook.utils.metalink_utils import build_metalink

from .common import TESTS_HOME, MINI_ESGF_MASTER_DIR
Expand Down Expand Up @@ -77,3 +79,41 @@ def test_resolve_to_file_paths_urls(load_test_data):
f"{test_dir}/badc/cmip6/data/CMIP6/CMIP/E3SM-Project/E3SM-1-1"
"/historical/r1i1p1f1/Amon/rlus/gr/v20191211/rlus_Amon_E3SM-1-1_historical_r1i1p1f1_gr_201001-201412.nc",
]


def test_parse_wps_input():
obj = {
'operation': 'execute',
'version': '1.0.0',
'language': 'eng',
'identifier': 'subset',
'identifiers': 'subset', # TODO: why identifierS?
'store_execute': True,
'status': True,
'lineage': True,
'inputs': {
'time': [{
'identifier': 'time',
'type': 'literal',
'data_type': 'string',
'allowed_values': [{'type': 'anyvalue'}],
'data': '1970/1980',
}],
'time_components': [{
'identifier': 'time',
'type': 'literal',
'data_type': 'string',
'allowed_values': [{'type': 'anyvalue'}],
'data': 'year:1970,1980|month=01,02,03',
}],
},
'outputs': {},
'raw': False
}

request = WPSRequest()
request.json = obj

assert parse_wps_input(request.inputs, "time", default=None) == "1970/1980"
assert parse_wps_input(request.inputs, "time_components", default=None) == \
"year:1970,1980|month=01,02,03"
3 changes: 2 additions & 1 deletion tests/test_wps_subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ def test_wps_subset_c3s_cmip6():
def test_wps_subset_c3s_cmip6_time_components():
client = client_for(Service(processes=[Subset()], cfgfiles=[PYWPS_CFG]))
datainputs = f"collection={C3S_CMIP6_MON_COLLECTION}"
# datainputs += ";time=2015-01-01/2015-12-30"
# datainputs += ";time=2015/2016"
datainputs += ";time_components=year:2015,2016|month:01,02,03"
resp = client.get(
"?service=WPS&request=Execute&version=1.0.0&identifier=subset&datainputs={}".format(
datainputs
)
)
# print(resp.data)
assert_response_success(resp)
assert "meta4" in get_output(resp.xml)["output"]

Expand Down

0 comments on commit 96551d5

Please sign in to comment.