From eb6d68df2abc783a9f34071e99e42a5e57ba1a5a Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Tue, 10 Mar 2026 17:08:20 +0100 Subject: [PATCH] Add API tests for schema details --- lib/galaxy_test/api/test_tools.py | 40 ++++++++++++++++++++++ lib/galaxy_test/base/populators.py | 5 +++ test/functional/tools/sample_tool_conf.xml | 1 + 3 files changed, 46 insertions(+) diff --git a/lib/galaxy_test/api/test_tools.py b/lib/galaxy_test/api/test_tools.py index e2f16809ee6..3e6d7e72d09 100644 --- a/lib/galaxy_test/api/test_tools.py +++ b/lib/galaxy_test/api/test_tools.py @@ -324,6 +324,46 @@ class TestToolsApi(ApiTestCase, TestsTools): with pytest.raises(ValidationError): validate(instance={"parameter": "Foobar"}, schema=landing_schema) + @skip_without_tool("cat_data_and_sleep") + def test_tool_schema_metadata(self): + """Test that tool parameter JSON schemas include Galaxy metadata attributes.""" + + # cat_data_and_sleep has an integer param with label and help + schema = self.dataset_populator.get_request_schema("cat_data_and_sleep") + props = schema["properties"] + sleep_prop = props["sleep_time"] + assert sleep_prop["title"] == "Sleep" + assert "Optionally simulates computation" in sleep_prop["description"] + assert sleep_prop["gx_type"] == "gx_integer" + + # data param should have gx_type and gx_extensions + input1_prop = props["input1"] + assert input1_prop["title"] == "Concatenate Dataset" + assert input1_prop["gx_type"] == "gx_data" + assert "gx_extensions" in input1_prop + + # repeat param should have gx_type + queries_prop = props["queries"] + assert queries_prop["gx_type"] == "gx_repeat" + + @skip_without_tool("gx_int_min_max") + def test_tool_schema_min_max(self): + schema = self.dataset_populator.get_request_schema("gx_int_min_max") + param_prop = schema["properties"]["parameter"] + assert param_prop["gx_type"] == "gx_integer" + assert param_prop["gx_min"] == 0 + assert param_prop["gx_max"] == 10 + + @skip_without_tool("gx_select") + def test_tool_schema_select_options(self): + schema = self.dataset_populator.get_request_schema("gx_select") + param_prop = schema["properties"]["parameter"] + assert param_prop["gx_type"] == "gx_select" + assert "gx_options" in param_prop + option_values = [o["value"] for o in param_prop["gx_options"]] + assert "--ex1" in option_values + assert "ex2" in option_values + @skip_without_tool("test_data_source") @skip_if_github_down def test_data_source_ok_request(self): diff --git a/lib/galaxy_test/base/populators.py b/lib/galaxy_test/base/populators.py index 76ea3123a90..6e5776f11ae 100644 --- a/lib/galaxy_test/base/populators.py +++ b/lib/galaxy_test/base/populators.py @@ -1803,6 +1803,11 @@ class BaseDatasetPopulator(BasePopulator): api_asserts.assert_status_code_is_ok(response) return response.json() + def get_request_schema(self, tool_id: str) -> dict[str, Any]: + response = self._get(f"tools/{tool_id}/parameter_request_schema") + api_asserts.assert_status_code_is_ok(response) + return response.json() + def get_history_tool_requests(self, history_id: str) -> list[dict[str, Any]]: response = self._get(f"histories/{history_id}/tool_requests") api_asserts.assert_status_code_is_ok(response) diff --git a/test/functional/tools/sample_tool_conf.xml b/test/functional/tools/sample_tool_conf.xml index df1a030afa7..f94478909b5 100644 --- a/test/functional/tools/sample_tool_conf.xml +++ b/test/functional/tools/sample_tool_conf.xml @@ -336,6 +336,7 @@ +