From 0e4e1d9249a47fd769dd6696201b8f8c4c5b1a20 Mon Sep 17 00:00:00 2001 From: Sergey Golitsynskiy Date: Tue, 16 Jul 2019 20:15:45 -0400 Subject: [PATCH] Restructure unit tests for tool_util package This replaces a previous (now closed) PR: https://github.com/galaxyproject/galaxy/pull/8279 A few changes: - tests for code in galaxy/tool_util moved under test/unit/tool_util - common parts (used in both tools and tool_util) factored out into unittest_utils/sample_data.py - symlink to sample_data.py in test/unit/tool_util/ is needed to make the tool_util package tests run. This is not an ideal solution, but it avoids duplication of the sample data used by tests in tools/ and tool_util/. --- packages/tool_util/tests/sample_data.py | 1 + .../tool_util/tests/test_conda_resolution.py | 2 +- .../tool_util/tests/test_output_checker.py | 2 +- packages/tool_util/tests/test_parsing.py | 2 +- packages/tool_util/tests/test_tool_deps.py | 2 +- packages/tool_util/tests/test_tool_loader.py | 2 +- packages/tool_util/tests/test_util.py | 1 + packages/tool_util/tests/util.py | 2 +- test/unit/tool_util/__init__.py | 0 test/unit/tool_util/sample_data.py | 1 + .../test_conda_resolution.py | 0 .../test_output_checker.py | 0 .../unit/{tools => tool_util}/test_parsing.py | 0 .../{tools => tool_util}/test_tool_deps.py | 0 .../{tools => tool_util}/test_tool_loader.py | 19 +------------------ test/unit/{tools => tool_util}/test_util.py | 0 test/unit/{tools => tool_util}/util.py | 0 test/unit/tools/test_toolbox.py | 5 +---- test/unit/unittest_utils/sample_data.py | 17 +++++++++++++++++ 19 files changed, 28 insertions(+), 28 deletions(-) create mode 120000 packages/tool_util/tests/sample_data.py create mode 120000 packages/tool_util/tests/test_util.py create mode 100644 test/unit/tool_util/__init__.py create mode 120000 test/unit/tool_util/sample_data.py rename test/unit/{tools => tool_util}/test_conda_resolution.py (100%) rename test/unit/{tools => tool_util}/test_output_checker.py (100%) rename test/unit/{tools => tool_util}/test_parsing.py (100%) rename test/unit/{tools => tool_util}/test_tool_deps.py (100%) rename test/unit/{tools => tool_util}/test_tool_loader.py (94%) rename test/unit/{tools => tool_util}/test_util.py (100%) rename test/unit/{tools => tool_util}/util.py (100%) create mode 100644 test/unit/unittest_utils/sample_data.py diff --git a/packages/tool_util/tests/sample_data.py b/packages/tool_util/tests/sample_data.py new file mode 120000 index 00000000000..dc903e91c44 --- /dev/null +++ b/packages/tool_util/tests/sample_data.py @@ -0,0 +1 @@ +../../../test/unit/unittest_utils/sample_data.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_conda_resolution.py b/packages/tool_util/tests/test_conda_resolution.py index 645faad4496..ad0efe1c3b9 120000 --- a/packages/tool_util/tests/test_conda_resolution.py +++ b/packages/tool_util/tests/test_conda_resolution.py @@ -1 +1 @@ -../../../test/unit/tools/test_conda_resolution.py \ No newline at end of file +../../../test/unit/tool_util/test_conda_resolution.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_output_checker.py b/packages/tool_util/tests/test_output_checker.py index 2a54b77ca94..9d5d6522f67 120000 --- a/packages/tool_util/tests/test_output_checker.py +++ b/packages/tool_util/tests/test_output_checker.py @@ -1 +1 @@ -../../../test/unit/tools/test_output_checker.py \ No newline at end of file +../../../test/unit/tool_util/test_output_checker.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_parsing.py b/packages/tool_util/tests/test_parsing.py index b21638588e4..c2ed25042dd 120000 --- a/packages/tool_util/tests/test_parsing.py +++ b/packages/tool_util/tests/test_parsing.py @@ -1 +1 @@ -../../../test/unit/tools/test_parsing.py \ No newline at end of file +../../../test/unit/tool_util/test_parsing.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_tool_deps.py b/packages/tool_util/tests/test_tool_deps.py index 34701999330..0c3f256d878 120000 --- a/packages/tool_util/tests/test_tool_deps.py +++ b/packages/tool_util/tests/test_tool_deps.py @@ -1 +1 @@ -../../../test/unit/tools/test_tool_deps.py \ No newline at end of file +../../../test/unit/tool_util/test_tool_deps.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_tool_loader.py b/packages/tool_util/tests/test_tool_loader.py index 572b75ae0a5..fb88b8ae6c5 120000 --- a/packages/tool_util/tests/test_tool_loader.py +++ b/packages/tool_util/tests/test_tool_loader.py @@ -1 +1 @@ -../../../test/unit/tools/test_tool_loader.py \ No newline at end of file +../../../test/unit/tool_util/test_tool_loader.py \ No newline at end of file diff --git a/packages/tool_util/tests/test_util.py b/packages/tool_util/tests/test_util.py new file mode 120000 index 00000000000..e6343216e6f --- /dev/null +++ b/packages/tool_util/tests/test_util.py @@ -0,0 +1 @@ +../../../test/unit/tool_util/test_util.py \ No newline at end of file diff --git a/packages/tool_util/tests/util.py b/packages/tool_util/tests/util.py index 9469bc59223..f757327f2d9 120000 --- a/packages/tool_util/tests/util.py +++ b/packages/tool_util/tests/util.py @@ -1 +1 @@ -../../../test/unit/tools/util.py \ No newline at end of file +../../../test/unit/tool_util/util.py \ No newline at end of file diff --git a/test/unit/tool_util/__init__.py b/test/unit/tool_util/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/unit/tool_util/sample_data.py b/test/unit/tool_util/sample_data.py new file mode 120000 index 00000000000..3b4ed484f80 --- /dev/null +++ b/test/unit/tool_util/sample_data.py @@ -0,0 +1 @@ +../unittest_utils/sample_data.py \ No newline at end of file diff --git a/test/unit/tools/test_conda_resolution.py b/test/unit/tool_util/test_conda_resolution.py similarity index 100% rename from test/unit/tools/test_conda_resolution.py rename to test/unit/tool_util/test_conda_resolution.py diff --git a/test/unit/tools/test_output_checker.py b/test/unit/tool_util/test_output_checker.py similarity index 100% rename from test/unit/tools/test_output_checker.py rename to test/unit/tool_util/test_output_checker.py diff --git a/test/unit/tools/test_parsing.py b/test/unit/tool_util/test_parsing.py similarity index 100% rename from test/unit/tools/test_parsing.py rename to test/unit/tool_util/test_parsing.py diff --git a/test/unit/tools/test_tool_deps.py b/test/unit/tool_util/test_tool_deps.py similarity index 100% rename from test/unit/tools/test_tool_deps.py rename to test/unit/tool_util/test_tool_deps.py diff --git a/test/unit/tools/test_tool_loader.py b/test/unit/tool_util/test_tool_loader.py similarity index 94% rename from test/unit/tools/test_tool_loader.py rename to test/unit/tool_util/test_tool_loader.py index f07c1e8c2b5..dde14997ec4 100644 --- a/test/unit/tools/test_tool_loader.py +++ b/test/unit/tool_util/test_tool_loader.py @@ -1,27 +1,10 @@ import os from shutil import rmtree -from string import Template from tempfile import mkdtemp from galaxy.tool_util.loader import load_tool, template_macro_params from galaxy.util import parse_xml - - -SIMPLE_TOOL_WITH_MACRO = """ - - - external.xml - -""" - -SIMPLE_MACRO = Template(""" - - $tool_version - - - - -""") +from .sample_data import SIMPLE_TOOL_WITH_MACRO, SIMPLE_MACRO def test_loader(): diff --git a/test/unit/tools/test_util.py b/test/unit/tool_util/test_util.py similarity index 100% rename from test/unit/tools/test_util.py rename to test/unit/tool_util/test_util.py diff --git a/test/unit/tools/util.py b/test/unit/tool_util/util.py similarity index 100% rename from test/unit/tools/util.py rename to test/unit/tool_util/util.py diff --git a/test/unit/tools/test_toolbox.py b/test/unit/tools/test_toolbox.py index e592f8e43d2..5c892ac843d 100644 --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -14,12 +14,9 @@ from galaxy.model import tool_shed_install from galaxy.model.tool_shed_install import mapping from galaxy.tools import ToolBox from galaxy.tools.cache import ToolCache -from .test_tool_loader import ( - SIMPLE_MACRO, - SIMPLE_TOOL_WITH_MACRO -) from .test_toolbox_filters import mock_trans from ..tools_support import UsesApp, UsesTools +from ..unittest_utils.sample_data import SIMPLE_TOOL_WITH_MACRO, SIMPLE_MACRO log = logging.getLogger(__name__) diff --git a/test/unit/unittest_utils/sample_data.py b/test/unit/unittest_utils/sample_data.py new file mode 100644 index 00000000000..dc0bcb02093 --- /dev/null +++ b/test/unit/unittest_utils/sample_data.py @@ -0,0 +1,17 @@ +from string import Template + +SIMPLE_TOOL_WITH_MACRO = """ + + + external.xml + +""" + +SIMPLE_MACRO = Template(""" + + $tool_version + + + + +""")