Skip to content

Commit 97caddb

Browse files
committed
Add tests
1 parent e5da20f commit 97caddb

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

test/unit/app/tools/test_tool_serialization_roundtrip.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,23 @@ def test_repopulate_after_serialization_yaml():
3636
)
3737

3838

39+
def test_repopulate_applies_guid():
40+
tool = simple_constructs_tool()
41+
raw_tool_source, tool_source_class = tool.to_raw_tool_source()
42+
guid = "toolshed.example.com/repos/owner/repo/simple_constructs_y/1.0"
43+
44+
app = mock_app_for_tool_support()
45+
rebuilt = create_tool_from_representation(
46+
app,
47+
raw_tool_source,
48+
tool.tool_dir,
49+
tool_source_class,
50+
guid=guid,
51+
)
52+
assert rebuilt.id == guid
53+
assert rebuilt.old_id == "simple_constructs_y"
54+
55+
3956
def simple_constructs_tool() -> Tool:
4057
tool_path = functional_test_tool_path("simple_constructs.yml")
4158
tool_source = functional_test_tool_source("simple_constructs_y")

test/unit/tool_util/test_parameter_convert.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ def test_multi_data():
121121
assert encoded_state.input_state["parameter"][1]["id"] == EXAMPLE_ID_2_ENCODED
122122

123123

124+
def test_encode_optional_data_collection_none():
125+
tool_source = tool_source_for("parameters/gx_data_collection_optional")
126+
bundle = input_models_for_tool_source(tool_source)
127+
internal_state = RequestInternalToolState({"parameter": None})
128+
encoded_state = encode(internal_state, bundle, _fake_encode)
129+
assert encoded_state.input_state["parameter"] is None
130+
131+
124132
def test_landing_encode_data():
125133
tool_source = tool_source_for("parameters/gx_data")
126134
bundle = input_models_for_tool_source(tool_source)

0 commit comments

Comments
 (0)