Skip to content

Commit

Permalink
WIP: maybe dont want, more ps testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Oct 1, 2024
1 parent fe3c32a commit 1be235d
Showing 1 changed file with 39 additions and 23 deletions.
62 changes: 39 additions & 23 deletions test/unit/app/tools/test_populate_state.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from galaxy.util import XML
from galaxy.util.bunch import Bunch
from galaxy.app_unittest_utils.galaxy_mock import MockTrans
from galaxy.app_unittest_utils.tools_support import UsesTools
from galaxy.tool_util.unittest_utils import functional_test_tool_path
from galaxy.tools.parameters import populate_state
from galaxy.tools.parameters.basic import (
BooleanToolParameter,
Expand All @@ -11,45 +10,62 @@
Conditional,
Repeat,
)
from galaxy.tool_util.unittest_utils import functional_test_tool_path
from galaxy.util import XML
from galaxy.util.bunch import Bunch
from galaxy.util.unittest import TestCase


trans = Bunch(workflow_building_mode=False)


def test_populate_state():

a = TextToolParameter(None, XML('<param name="a"/>'))
b = Repeat('b')
b = Repeat("b")
b.min = 0
b.max = 1
c = TextToolParameter(None, XML('<param name="c"/>'))
d = Repeat('d')
d = Repeat("d")
d.min = 0
d.max = 1
e = TextToolParameter(None, XML('<param name="e"/>'))
f = Conditional('f')
f = Conditional("f")
g = BooleanToolParameter(None, XML('<param name="g"/>'))
h = TextToolParameter(None, XML('<param name="h"/>'))
i = TextToolParameter(None, XML('<param name="i"/>'))
b.inputs = dict([('c', c), ('d', d)])
d.inputs = dict([('e', e), ('f', f)])
b.inputs = dict([("c", c), ("d", d)])
d.inputs = dict([("e", e), ("f", f)])
f.test_param = g
f.cases = [Bunch(value='true', inputs= { 'h': h }), Bunch(value='false', inputs= { 'i': i })]
inputs = dict([('a',a),('b',b)])
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)])
f.cases = [Bunch(value="true", inputs={"h": h}), Bunch(value="false", inputs={"i": i})]
inputs = dict([("a", a), ("b", b)])
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)])
state = {}
populate_state(trans, inputs, flat, state, check=False)
assert state['a'] == 1
assert state['b'][0]['c'] == 2
assert state['b'][0]['d'][0]['e'] == 3
assert state['b'][0]['d'][0]['f']['h'] == 4
assert state["a"] == 1
assert state["b"][0]["c"] == 2
assert state["b"][0]["d"][0]["e"] == 3
assert state["b"][0]["d"][0]["f"]["h"] == 4
# now test with input_format='21.01'
nested = {'a': 1, 'b': [{'c': 2, 'd': [{'e': 3, 'f': {'h': 4, 'g': True}}]}]}
nested = {"a": 1, "b": [{"c": 2, "d": [{"e": 3, "f": {"h": 4, "g": True}}]}]}
state_new = {}
populate_state(trans, inputs, nested, state_new, check=False, input_format='21.01')
assert state_new['a'] == 1
assert state_new['b'][0]['c'] == 2
assert state_new['b'][0]['d'][0]['e'] == 3
assert state_new['b'][0]['d'][0]['f']['h'] == 4
populate_state(trans, inputs, nested, state_new, check=False, input_format="21.01")
assert state_new["a"] == 1
assert state_new["b"][0]["c"] == 2
assert state_new["b"][0]["d"][0]["e"] == 3
assert state_new["b"][0]["d"][0]["f"]["h"] == 4


class TestMetadata(TestCase, UsesTools):
def setUp(self):
super().setUp()
self.setup_app()
self.trans = MockTrans(app=self.app)

def test_boolean_validation(self):
source_file_name = functional_test_tool_path("parameters/gx_data_column.xml")
tool = self._init_tool_for_path(source_file_name)
incoming = {"ref_parameter": {"src": "hda", "id": 89}, "parameter": "m89"}
state_new = {}
errors = {}
populate_state(self.trans, tool.inputs, incoming, state_new, errors=errors, check=True, input_format="21.01")
print(state_new)
assert False

0 comments on commit 1be235d

Please sign in to comment.