Skip to content

Commit 6178f56

Browse files
fixup: for batch mode
test data generation needs to remove whens and set the select parameter
1 parent 98e9eb5 commit 6178f56

File tree

19 files changed

+70
-189
lines changed

19 files changed

+70
-189
lines changed

ctdconverter/galaxy/converter.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55
import os
66
import os.path
7+
import random
78
import re
89
import sys
910
from collections import OrderedDict
@@ -51,6 +52,8 @@
5152

5253
REQUIRED_MACROS = [REQUIREMENTS_MACRO_NAME, STDIO_MACRO_NAME, ADVANCED_OPTIONS_NAME + "_macro"]
5354

55+
random.seed(42)
56+
5457

5558
class ExitCode:
5659
def __init__(self, code_range="", level="", description=None):
@@ -1749,14 +1752,27 @@ def create_tests(parent, inputs=None, outputs=None):
17491752
for a in attrib:
17501753
del node.attrib[a]
17511754
node.attrib[a] = attrib[a]
1755+
# this should be batch mode conditionals
1756+
# select yes/no at random
1757+
if node.tag == "conditional":
1758+
select = node.find("./param")
1759+
options = [x.attrib["value"] for x in select.findall("./option")]
1760+
option = random.choice(options)
1761+
select.attrib["value"] = option
1762+
for when in node.findall(".//when"):
1763+
when.tag = "delete_node"
1764+
if when.attrib["value"] != option:
1765+
continue
1766+
for p in when:
1767+
node.append(p)
1768+
17521769
if node.tag == "expand" and node.attrib["macro"] == ADVANCED_OPTIONS_NAME + "_macro":
17531770
node.tag = "section"
17541771
node.attrib["name"] = ADVANCED_OPTIONS_NAME
17551772
if "type" not in node.attrib:
17561773
continue
17571774

1758-
if (node.attrib["type"] == "select" and "true" in {_.attrib.get("selected", "false") for _ in node}) or\
1759-
(node.attrib["type"] == "select" and node.attrib.get("value", "") != ""):
1775+
if node.attrib["type"] == "select" and node.getparent().tag != "conditional" and (("true" in {_.attrib.get("selected", "false") for _ in node}) or (node.attrib.get("value", "") != "")):
17601776
node.tag = "delete_node"
17611777
continue
17621778

@@ -1777,7 +1793,9 @@ def create_tests(parent, inputs=None, outputs=None):
17771793
elif node.attrib["type"] == "float" and node.attrib["value"] == "":
17781794
node.attrib["value"] = "1.0"
17791795
elif node.attrib["type"] == "select":
1780-
if node.attrib.get("display", None) == "radio" or node.attrib.get("multiple", "false") == "false":
1796+
if node.getparent().tag == "conditional": # set batch mode conditional select, this is done elsewhere
1797+
pass
1798+
elif node.attrib.get("display", None) == "radio" or node.attrib.get("multiple", "false") == "false":
17811799
node.attrib["value"] = node[0].attrib["value"]
17821800
elif node.attrib.get("multiple", None) == "true":
17831801
node.attrib["value"] = ",".join([_.attrib["value"] for _ in node if "value" in _.attrib])

tests/test-data/ifile.xml

Lines changed: 30 additions & 162 deletions
Large diffs are not rendered by default.

tests/test-data/ofile-mult-typeparam.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,23 +125,13 @@ ${' '.join(["&& mv -n 'test_section_sect_mandatory_mandatoryinput/%(bn)s/%(id)s.
125125
<param name="mandatory_mandatoryinput_type" value="ewt"/>
126126
<conditional name="inp_mandatory_mandatoryinput_cond">
127127
<param name="inp_mandatory_mandatoryinput_select" value="no"/>
128-
<when value="no">
129-
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="0test.ext,0test2.ext"/>
130-
</when>
131-
<when value="yes">
132-
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="1test.ext"/>
133-
</when>
128+
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="1test.ext,1test2.ext"/>
134129
</conditional>
135130
<section name="test_section">
136131
<param name="sect_mandatory_mandatoryinput_type" value="eut"/>
137132
<conditional name="sect_inp_mandatory_mandatoryinput_cond">
138133
<param name="sect_inp_mandatory_mandatoryinput_select" value="no"/>
139-
<when value="no">
140-
<param name="sect_inp_mandatory_mandatoryinput" ftype="tsv" value="2test.ext,2test2.ext"/>
141-
</when>
142-
<when value="yes">
143-
<param name="sect_inp_mandatory_mandatoryinput" ftype="tsv" value="3test.ext"/>
144-
</when>
134+
<param name="sect_inp_mandatory_mandatoryinput" ftype="tsv" value="3test.ext,3test2.ext"/>
145135
</conditional>
146136
</section>
147137
<section name="adv_opts"/>

tests/test-data/ofile-mult.xml

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -122,21 +122,11 @@ ${' '.join(["&& mv -n 'mandatory_mandatoryinput/%(bn)s/%(id)s.%(gext)s' 'mandato
122122
<test expect_num_outputs="1">
123123
<conditional name="inp_mandatory_mandatoryinput_cond">
124124
<param name="inp_mandatory_mandatoryinput_select" value="no"/>
125-
<when value="no">
126-
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="0test.ext,0test2.ext"/>
127-
</when>
128-
<when value="yes">
129-
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="1test.ext"/>
130-
</when>
125+
<param name="inp_mandatory_mandatoryinput" ftype="tsv" value="1test.ext,1test2.ext"/>
131126
</conditional>
132127
<conditional name="inp_optional_mandatoryinput_cond">
133128
<param name="inp_optional_mandatoryinput_select" value="no"/>
134-
<when value="no">
135-
<param name="inp_optional_mandatoryinput" ftype="tsv" value="2test.ext,2test2.ext"/>
136-
</when>
137-
<when value="yes">
138-
<param name="inp_optional_mandatoryinput" ftype="tsv" value="3test.ext"/>
139-
</when>
129+
<param name="inp_optional_mandatoryinput" ftype="tsv" value="3test.ext,3test2.ext"/>
140130
</conditional>
141131
<section name="adv_opts"/>
142132
<output_collection name="mandatory_mandatoryinput" count="0"/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.ext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test2.ext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.ext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test2.ext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test.ext
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test2.ext

0 commit comments

Comments
 (0)