Skip to content

Commit 1be235d

Browse files
committed
WIP: maybe dont want, more ps testing
1 parent fe3c32a commit 1be235d

1 file changed

Lines changed: 39 additions & 23 deletions

File tree

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
from galaxy.util import XML
2-
from galaxy.util.bunch import Bunch
31
from galaxy.app_unittest_utils.galaxy_mock import MockTrans
42
from galaxy.app_unittest_utils.tools_support import UsesTools
3+
from galaxy.tool_util.unittest_utils import functional_test_tool_path
54
from galaxy.tools.parameters import populate_state
65
from galaxy.tools.parameters.basic import (
76
BooleanToolParameter,
@@ -11,45 +10,62 @@
1110
Conditional,
1211
Repeat,
1312
)
14-
from galaxy.tool_util.unittest_utils import functional_test_tool_path
13+
from galaxy.util import XML
14+
from galaxy.util.bunch import Bunch
1515
from galaxy.util.unittest import TestCase
1616

17-
1817
trans = Bunch(workflow_building_mode=False)
1918

2019

2120
def test_populate_state():
22-
21+
2322
a = TextToolParameter(None, XML('<param name="a"/>'))
24-
b = Repeat('b')
23+
b = Repeat("b")
2524
b.min = 0
2625
b.max = 1
2726
c = TextToolParameter(None, XML('<param name="c"/>'))
28-
d = Repeat('d')
27+
d = Repeat("d")
2928
d.min = 0
3029
d.max = 1
3130
e = TextToolParameter(None, XML('<param name="e"/>'))
32-
f = Conditional('f')
31+
f = Conditional("f")
3332
g = BooleanToolParameter(None, XML('<param name="g"/>'))
3433
h = TextToolParameter(None, XML('<param name="h"/>'))
3534
i = TextToolParameter(None, XML('<param name="i"/>'))
36-
b.inputs = dict([('c', c), ('d', d)])
37-
d.inputs = dict([('e', e), ('f', f)])
35+
b.inputs = dict([("c", c), ("d", d)])
36+
d.inputs = dict([("e", e), ("f", f)])
3837
f.test_param = g
39-
f.cases = [Bunch(value='true', inputs= { 'h': h }), Bunch(value='false', inputs= { 'i': i })]
40-
inputs = dict([('a',a),('b',b)])
41-
flat = dict([('a', 1), ('b_0|c', 2), ('b_0|d_0|e', 3), ('b_0|d_0|f|h', 4), ('b_0|d_0|f|g', True)])
38+
f.cases = [Bunch(value="true", inputs={"h": h}), Bunch(value="false", inputs={"i": i})]
39+
inputs = dict([("a", a), ("b", b)])
40+
flat = dict([("a", 1), ("b_0|c", 2), ("b_0|d_0|e", 3), ("b_0|d_0|f|h", 4), ("b_0|d_0|f|g", True)])
4241
state = {}
4342
populate_state(trans, inputs, flat, state, check=False)
44-
assert state['a'] == 1
45-
assert state['b'][0]['c'] == 2
46-
assert state['b'][0]['d'][0]['e'] == 3
47-
assert state['b'][0]['d'][0]['f']['h'] == 4
43+
assert state["a"] == 1
44+
assert state["b"][0]["c"] == 2
45+
assert state["b"][0]["d"][0]["e"] == 3
46+
assert state["b"][0]["d"][0]["f"]["h"] == 4
4847
# now test with input_format='21.01'
49-
nested = {'a': 1, 'b': [{'c': 2, 'd': [{'e': 3, 'f': {'h': 4, 'g': True}}]}]}
48+
nested = {"a": 1, "b": [{"c": 2, "d": [{"e": 3, "f": {"h": 4, "g": True}}]}]}
5049
state_new = {}
51-
populate_state(trans, inputs, nested, state_new, check=False, input_format='21.01')
52-
assert state_new['a'] == 1
53-
assert state_new['b'][0]['c'] == 2
54-
assert state_new['b'][0]['d'][0]['e'] == 3
55-
assert state_new['b'][0]['d'][0]['f']['h'] == 4
50+
populate_state(trans, inputs, nested, state_new, check=False, input_format="21.01")
51+
assert state_new["a"] == 1
52+
assert state_new["b"][0]["c"] == 2
53+
assert state_new["b"][0]["d"][0]["e"] == 3
54+
assert state_new["b"][0]["d"][0]["f"]["h"] == 4
55+
56+
57+
class TestMetadata(TestCase, UsesTools):
58+
def setUp(self):
59+
super().setUp()
60+
self.setup_app()
61+
self.trans = MockTrans(app=self.app)
62+
63+
def test_boolean_validation(self):
64+
source_file_name = functional_test_tool_path("parameters/gx_data_column.xml")
65+
tool = self._init_tool_for_path(source_file_name)
66+
incoming = {"ref_parameter": {"src": "hda", "id": 89}, "parameter": "m89"}
67+
state_new = {}
68+
errors = {}
69+
populate_state(self.trans, tool.inputs, incoming, state_new, errors=errors, check=True, input_format="21.01")
70+
print(state_new)
71+
assert False

0 commit comments

Comments
 (0)