Skip to content

Commit

Permalink
Merge pull request #17134 from mvdbeek/workflow_test_schema_support
Browse files Browse the repository at this point in the history
[23.2] Enhance xsd schema and allow simpler assertion lists
  • Loading branch information
mvdbeek authored Dec 6, 2023
2 parents dca5914 + 0f76e6a commit 149e8d3
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 14 deletions.
11 changes: 10 additions & 1 deletion lib/galaxy/tool_util/parser/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def _parse_test(i, test_dict) -> ToolSourceTest:
return test_dict


def __to_test_assert_list(assertions) -> AssertionList:
def to_test_assert_list(assertions) -> AssertionList:
def expand_dict_form(item):
key, value = item
new_value = value.copy()
Expand All @@ -281,6 +281,12 @@ def expand_dict_form(item):
for assertion in assertions:
# TODO: not handling nested assertions correctly,
# not sure these are used though.
if "that" not in assertion:
new_assertion = {}
for assertion_key, assertion_value in assertion.items():
new_assertion["that"] = assertion_key
new_assertion.update(assertion_value)
assertion = new_assertion
children = []
if "children" in assertion:
children = assertion["children"]
Expand All @@ -295,6 +301,9 @@ def expand_dict_form(item):
return assert_list or None # XML variant is None if no assertions made


__to_test_assert_list = to_test_assert_list


class YamlPageSource(PageSource):
def __init__(self, inputs_list):
self.inputs_list = inputs_list
Expand Down
41 changes: 28 additions & 13 deletions lib/galaxy/tool_util/xsd/galaxy.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -7322,24 +7322,39 @@ and ``contains``. In addition there is ``sim_size`` which is discouraged in favo
<xs:annotation>
<xs:documentation xml:lang="en">Documentation for PermissiveBoolean</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="True"/>
<xs:enumeration value="False"/>
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:boolean"/>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="0"/>
<xs:enumeration value="1"/>
<xs:enumeration value="true"/>
<xs:enumeration value="false"/>
<xs:enumeration value="True"/>
<xs:enumeration value="False"/>
<xs:enumeration value="yes"/>
<xs:enumeration value="no"/>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:simpleType name="Bytes">
<xs:annotation>
<xs:documentation xml:lang="en">Number of bytes allowing for suffix (k|K|M|G|P|E)i? </xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:pattern value="(0|[1-9][0-9]*)([kKMGTPE]i?)?"></xs:pattern>
</xs:restriction>
<xs:union>
<xs:simpleType>
<xs:restriction base="xs:integer">
</xs:restriction>
</xs:simpleType>
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="(0|[1-9][0-9]*)([kKMGTPE]i?)?"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:union>
</xs:simpleType>
<xs:complexType name="EdamTopics">
<xs:annotation>
Expand Down
40 changes: 40 additions & 0 deletions test/unit/tool_util/test_test_parsing.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import yaml

from galaxy.tool_util.parser.yaml import to_test_assert_list

# Legacy style
ASSERT_THAT_LIST = yaml.safe_load(
"""
- that: "has_text"
text: "Number of input reads |\t1051466"
- that: "has_text"
text: "Uniquely mapped reads number |\t871202"
"""
)
# New list of assertion style
ASSERT_LIST = yaml.safe_load(
"""
- has_text:
text: "Number of input reads |\t1051466"
- has_text:
text: "Uniquely mapped reads number |\t871202"
"""
)
# Singleton assertion
SIMPLE_ASSERT = {"has_text": {"text": "Number of input reads |\t1051466"}}


def test_assert_that_list_to_test_assert_list():
to_test_assert_list(ASSERT_THAT_LIST)


def test_assert_list_to_test_assert_list():
to_test_assert_list(ASSERT_LIST)


def test_simple_assert_to_test_assert_list():
to_test_assert_list(SIMPLE_ASSERT)


def test_assert_legacy_same_as_new_list_style():
assert to_test_assert_list(ASSERT_THAT_LIST) == to_test_assert_list(ASSERT_THAT_LIST)

0 comments on commit 149e8d3

Please sign in to comment.