diff --git a/tests/functional/test_wps_package.py b/tests/functional/test_wps_package.py index 8c00acf00..66513d724 100644 --- a/tests/functional/test_wps_package.py +++ b/tests/functional/test_wps_package.py @@ -1817,28 +1817,32 @@ def test_enum_array_and_multi_format_inputs_from_wps_xml_reference(self): assert "format" not in pkg["inputs"][0] assert isinstance(pkg["inputs"][0]["type"], list) # single entry of enum allowed values - assert len(pkg["inputs"][0]["type"]) == 2, "single type and array type of same base" - assert isinstance(pkg["inputs"][0]["type"][0], dict), "enum base type expected since allowed values" - assert pkg["inputs"][0]["type"][0]["type"] == "enum" - assert isinstance(pkg["inputs"][0]["type"][0]["symbols"], list) - assert len(pkg["inputs"][0]["type"][0]["symbols"]) == 220 - assert all(isinstance(s, str) for s in pkg["inputs"][0]["type"][0]["symbols"]) + assert len(pkg["inputs"][0]["type"]) == 3, "default value (null) + single type + array type of same base" + assert pkg["inputs"][0]["type"][0] == "null", "XML defaultValue should result in 'null' as valid unspecified" + assert "default" in pkg["inputs"][0] + assert pkg["inputs"][0]["default"] == "DEU", "CWL default value should match extracted defaultValue from XML" + assert isinstance(pkg["inputs"][0]["type"][1], dict), "enum base type expected since allowed values" + assert pkg["inputs"][0]["type"][1]["type"] == "enum" + assert isinstance(pkg["inputs"][0]["type"][1]["symbols"], list) + assert len(pkg["inputs"][0]["type"][1]["symbols"]) == 220 + assert all(isinstance(s, str) for s in pkg["inputs"][0]["type"][1]["symbols"]) # array type of same enum allowed values - assert pkg["inputs"][0]["type"][1]["type"] == "array" - assert pkg["inputs"][0]["type"][1]["items"]["type"] == "enum" - assert isinstance(pkg["inputs"][0]["type"][1]["items"]["symbols"], list) - assert len(pkg["inputs"][0]["type"][1]["items"]["symbols"]) == 220 - assert all(isinstance(s, str) for s in pkg["inputs"][0]["type"][1]["items"]["symbols"]) + assert pkg["inputs"][0]["type"][2]["type"] == "array" + assert pkg["inputs"][0]["type"][2]["items"]["type"] == "enum" + assert isinstance(pkg["inputs"][0]["type"][2]["items"]["symbols"], list) + assert len(pkg["inputs"][0]["type"][2]["items"]["symbols"]) == 220 + assert all(isinstance(s, str) for s in pkg["inputs"][0]["type"][2]["items"]["symbols"]) # second input assert pkg["inputs"][1]["id"] == "mosaic" assert pkg["inputs"][1]["default"] == "null" assert "format" not in pkg["inputs"][1] assert isinstance(pkg["inputs"][1]["type"], list), "default 'null' result type formed with it" assert len(pkg["inputs"][1]["type"]) == 2 - assert pkg["inputs"][1]["type"][0] == "null" + assert pkg["inputs"][1]["type"][0] == "null", "CWL omitted input expect from minOccurs=0 from WPS input" assert pkg["inputs"][1]["type"][1] == "boolean" assert pkg["inputs"][2]["id"] == "resource" - assert "default" not in pkg["inputs"][2] + assert "default" not in pkg["inputs"][2], \ + "WPS 'default format media-type' with minOccurs=1 must not result in CWL input with 'default' value" assert isinstance(pkg["inputs"][2]["type"], list), "single and array File" assert len(pkg["inputs"][2]["type"]) == 2 assert pkg["inputs"][2]["type"][0] == "File", "single File type" @@ -1861,8 +1865,14 @@ def test_enum_array_and_multi_format_inputs_from_wps_xml_reference(self): assert proc["inputs"][0]["title"] == "Region" assert "abstract" not in proc["inputs"][0], "Field 'abstract' should be replaced by 'description'." assert proc["inputs"][0]["description"] == "Country code, see ISO-3166-3" - assert proc["inputs"][0]["minOccurs"] == 1 + assert proc["inputs"][0]["minOccurs"] == 0, \ + "Real XML indicates 'minOccurs=1' but also has 'defaultValue', Weaver should correct it." assert proc["inputs"][0]["maxOccurs"] == 220 + assert "literalDataDomains" in proc["inputs"][0] + assert "defaultValue" in proc["inputs"][0]["literalDataDomains"][0] + assert len(proc["inputs"][0]["literalDataDomains"][0]["valueDefinition"]) == 220, \ + "List of all 220 region abbreviation explicitly provided is expected." + assert proc["inputs"][0]["literalDataDomains"][0]["defaultValue"] == "DEU" assert "formats" not in proc["inputs"][0] assert proc["inputs"][1]["id"] == "mosaic" assert proc["inputs"][1]["title"] == "Union of multiple regions" diff --git a/tests/processes/test_convert.py b/tests/processes/test_convert.py index 674a42386..ea1f7ca23 100644 --- a/tests/processes/test_convert.py +++ b/tests/processes/test_convert.py @@ -16,6 +16,7 @@ from weaver.processes.convert import ( DEFAULT_FORMAT, PACKAGE_ARRAY_MAX_SIZE, + any2cwl_io, cwl2wps_io, is_cwl_array_type, is_cwl_enum_type, diff --git a/tests/processes/test_wps_package.py b/tests/processes/test_wps_package.py index 22883db6b..7aa67a8e9 100644 --- a/tests/processes/test_wps_package.py +++ b/tests/processes/test_wps_package.py @@ -247,7 +247,7 @@ def test_stdout_stderr_logging_for_commandline_tool_success(): Execute a process and assert that stdout is correctly logged to log file upon successful process execution. """ with contextlib.ExitStack() as stack: - xml_file = stack.enter_context(tempfile.NamedTemporaryFile(suffix=".xml")) + xml_file = stack.enter_context(tempfile.NamedTemporaryFile(suffix=".xml")) # noqa workdir = stack.enter_context(tempfile.TemporaryDirectory()) process = MockProcess(shell_command="echo") wps_package_instance = MockWpsPackage(identifier=process["id"], title=process["title"], @@ -273,7 +273,7 @@ def test_stdout_stderr_logging_for_commandline_tool_failure(): Execute a process and assert that stderr is correctly logged to log file upon failing process execution. """ with contextlib.ExitStack() as stack: - xml_file = stack.enter_context(tempfile.NamedTemporaryFile(suffix=".xml")) + xml_file = stack.enter_context(tempfile.NamedTemporaryFile(suffix=".xml")) # noqa workdir = stack.enter_context(tempfile.TemporaryDirectory()) process = MockProcess(shell_command="not_existing_command") wps_package_instance = MockWpsPackage(identifier=process["id"], title=process["title"], diff --git a/weaver/processes/convert.py b/weaver/processes/convert.py index 6cf271d45..ebd1dab41 100644 --- a/weaver/processes/convert.py +++ b/weaver/processes/convert.py @@ -276,9 +276,9 @@ def ows2json_io(ows_io): if fmt["default"]: break - # fix inconsistencies of some process descriptions, both with minOccurs=1 and default format - if fmt_default: - json_io["min_occurs"] = 0 + # NOTE: + # Don't apply 'minOccurs=0' as in below literal case because default 'format' does not imply that unspecified + # input is valid, but rather that given an input without explicit 'format' specified, that 'default' is used. return json_io # add value contrains specifications if missing