Skip to content

Commit 43feb0e

Browse files
committed
Merge branch 'release_24.2' into release_25.0
2 parents 63dcf19 + 044442b commit 43feb0e

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

lib/galaxy/tool_util/linters/tests.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212

1313
from galaxy.tool_util.lint import Linter
1414
from galaxy.tool_util.parameters import validate_test_cases_for_tool_source
15-
from galaxy.tool_util_models.assertions import assertion_list
15+
from galaxy.tool_util.verify.parse import tag_structure_to_that_structure
16+
from galaxy.tool_util_models.assertions import (
17+
assertion_list,
18+
relaxed_assertion_list,
19+
)
1620
from galaxy.util import asbool
1721
from ._util import is_datasource
1822

@@ -148,15 +152,17 @@ def lint(cls, tool_source: "ToolSource", lint_ctx: "LintContext"):
148152
lint_ctx.warn("Failed to parse test dictionaries from tool - cannot lint assertions")
149153
return
150154
assert "tests" in raw_tests_dict
155+
# This really only allows coercion from strings, the values themselves will still be validated
156+
assert_list_model = relaxed_assertion_list if tool_source.language == "xml" else assertion_list
151157
for test_idx, test in enumerate(raw_tests_dict["tests"], start=1):
152158
# TODO: validate command, command_version, element tests. What about children?
153159
for output in test["outputs"]:
154160
asserts_raw = output.get("attributes", {}).get("assert_list") or []
155-
to_yaml_assertions = []
161+
processed_assertions = []
156162
for raw_assert in asserts_raw:
157-
to_yaml_assertions.append({"that": raw_assert["tag"], **raw_assert.get("attributes", {})})
163+
processed_assertions.append(tag_structure_to_that_structure(raw_assert))
158164
try:
159-
assertion_list.model_validate(to_yaml_assertions)
165+
assert_list_model.model_validate(processed_assertions)
160166
except Exception as e:
161167
error_str = _cleanup_pydantic_error(e)
162168
lint_ctx.warn(

test/unit/tool_util/test_tool_linters.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,23 @@
894894
</tests>
895895
</tool>
896896
"""
897+
ASSERTS_STRING_COERCION = """
898+
<tool id="id" name="name">
899+
<outputs>
900+
<data name="data_name" format="ome.tiff"/>
901+
</outputs>
902+
<tests>
903+
<test>
904+
<output name="data_name">
905+
<assert_contents>
906+
<!-- channels is defined as an integer, so coercion from string must be applied on validation -->
907+
<has_image_channels channels="3" />
908+
</assert_contents>
909+
</output>
910+
</test>
911+
</tests>
912+
</tool>
913+
"""
897914
TESTS_VALID = """
898915
<tool id="id" name="name">
899916
<outputs>
@@ -2042,6 +2059,12 @@ def test_tests_asserts(lint_ctx):
20422059
assert len(lint_ctx.error_messages) == 9
20432060

20442061

2062+
def test_tests_asserts_string_coercion(lint_ctx):
2063+
tool_source = get_xml_tool_source(ASSERTS_STRING_COERCION)
2064+
run_lint_module(lint_ctx, tests, tool_source)
2065+
assert len(lint_ctx.warn_messages) == 0, lint_ctx.warn_messages
2066+
2067+
20452068
def test_tests_assertion_models_valid(lint_ctx):
20462069
tool_source = get_xml_tool_source(VALID_CENTER_OF_MASS)
20472070
run_lint_module(lint_ctx, tests, tool_source)

0 commit comments

Comments
 (0)