From 7dca5cb1f6792b37fc0c4b4529c984e342ebc9df Mon Sep 17 00:00:00 2001 From: John Chilton Date: Sun, 28 Dec 2014 23:25:56 -0500 Subject: [PATCH] Bugfix for 44dfa6f and typos in unit tests that caused it to go undetected. --- .../tools/tool_panel_manager.py | 6 ++-- .../test_tool_panel_manager.py | 23 +++++++-------- test/unit/tools/test_toolbox.py | 28 +++++++++---------- 3 files changed, 30 insertions(+), 27 deletions(-) diff --git a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py index b6778bd4374..80bd0e10b1c 100644 --- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py +++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py @@ -475,8 +475,10 @@ class ToolPanelManager( object ): else: del has_elems[ tool_key ] if uninstall: - if tool_key in toolbox.integrated_tool_panel: - del toolbox.integrated_tool_panel[ tool_key ] + if hasattr( integrated_has_elems, "elems" ): + integrated_has_elems = integrated_has_elems.elems + if tool_key in integrated_has_elems: + del integrated_has_elems[ tool_key ] # Remove the tools from the toolbox's tools_by_id dictionary. for guid_to_remove in guids_to_remove: diff --git a/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py b/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py index 04a79eef355..9b9bd1d2da3 100644 --- a/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py +++ b/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py @@ -67,10 +67,10 @@ class ToolPanelManagerTestCase( BaseToolBoxTestCase ): self._setup_two_versions_remove_one( section=True, uninstall=False ) self._verify_version_2_removed_from_panel( ) # Still in tool conf since not uninstalled only deactivated... - assert "github.com/galaxyproect/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() + assert "github.com/galaxyproject/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() self._verify_tool_confs() - self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.1"], uninstall=False ) + self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.1"], uninstall=False ) # Now no versions of this tool are returned by toolbox. all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True ) @@ -84,24 +84,25 @@ class ToolPanelManagerTestCase( BaseToolBoxTestCase ): self._setup_two_versions_remove_one( section=True, uninstall=True ) self._verify_version_2_removed_from_panel( ) # Not in tool conf because it was uninstalled. - assert "github.com/galaxyproect/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() + assert "github.com/galaxyproject/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() + assert "tool_github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems self._verify_tool_confs() def test_deactivate_outside_section( self ): self._setup_two_versions_remove_one( section=False, uninstall=False ) self._verify_version_2_removed_from_panel( section=False ) # Still in tool conf since not uninstalled only deactivated... - assert "github.com/galaxyproect/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() + assert "github.com/galaxyproject/example/test_tool/0.2" in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() self._verify_tool_confs() def test_uninstall_outside_section( self ): self._setup_two_versions_remove_one( section=False, uninstall=True ) self._verify_version_2_removed_from_panel( section=False ) # Still in tool conf since not uninstalled only deactivated... - assert "github.com/galaxyproect/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() + assert "github.com/galaxyproject/example/test_tool/0.2" not in open(os.path.join(self.test_directory, "tool_conf.xml"), "r").read() self._verify_tool_confs() - self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.1"], uninstall=True ) + self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.1"], uninstall=True ) # Now no versions of this tool are returned by toolbox. all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True ) @@ -116,7 +117,7 @@ class ToolPanelManagerTestCase( BaseToolBoxTestCase ): self._setup_two_versions_in_config( section=True ) self._setup_two_versions() self.toolbox - self._remove_guids( ["github.com/galaxyproect/example/test_tool/0.2"], uninstall=uninstall ) + self._remove_guids( ["github.com/galaxyproject/example/test_tool/0.2"], uninstall=uninstall ) def _verify_version_2_removed_from_panel( self, section=True ): # Check that test_tool now only has one version... @@ -127,12 +128,12 @@ class ToolPanelManagerTestCase( BaseToolBoxTestCase ): if section: section = self.toolbox.tool_panel["tid"] assert len(section.elems) == 1 - assert section.elems.values()[0].id == "github.com/galaxyproect/example/test_tool/0.1" + assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1" - assert "github.com/galaxyproect/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems + assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel["tid"].elems else: - self.toolbox.tool_panel.values()[0].id == "github.com/galaxyproect/example/test_tool/0.1" - assert "github.com/galaxyproect/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel + self.toolbox.tool_panel.values()[0].id == "github.com/galaxyproject/example/test_tool/0.1" + assert "github.com/galaxyproject/example/test_tool/0.2" not in self.toolbox.integrated_tool_panel def _remove_guids( self, guids, uninstall, shed_tool_conf="tool_conf.xml" ): self.tpm.remove_guids( diff --git a/test/unit/tools/test_toolbox.py b/test/unit/tools/test_toolbox.py index 2031aeac07c..f04d92f292b 100644 --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -10,12 +10,12 @@ import tools_support CONFIG_TEST_TOOL_VERSION_TEMPLATE = string.Template( - """ + """ github.com example galaxyproject ${version} - github.com/galaxyproect/example/test_tool/0.${version} + github.com/galaxyproject/example/test_tool/0.${version} 0.${version} """ @@ -72,14 +72,14 @@ class BaseToolBoxTestCase( unittest.TestCase, tools_support.UsesApp, tools_supp def _setup_two_versions( self ): repository1 = self._repo_install( changeset="1" ) version1 = tool_shed_install.ToolVersion() - version1.tool_id = "github.com/galaxyproect/example/test_tool/0.1" + version1.tool_id = "github.com/galaxyproject/example/test_tool/0.1" version1.repository = repository1 self.app.install_model.context.add( version1 ) self.app.install_model.context.flush( ) repository2 = self._repo_install( changeset="2" ) version2 = tool_shed_install.ToolVersion() - version2.tool_id = "github.com/galaxyproect/example/test_tool/0.2" + version2.tool_id = "github.com/galaxyproject/example/test_tool/0.2" version2.repository = repository2 self.app.install_model.context.add( version2 ) @@ -184,7 +184,7 @@ class ToolBoxTestCase( BaseToolBoxTestCase ): # Assert only newer version of the tool loaded into the panel. section = self.toolbox.tool_panel["tid"] assert len(section.elems) == 1 - assert section.elems.values()[0].id == "github.com/galaxyproect/example/test_tool/0.2" + assert section.elems.values()[0].id == "github.com/galaxyproject/example/test_tool/0.2" def test_group_tools_out_of_section( self ): self._init_tool() @@ -212,10 +212,10 @@ class ToolBoxTestCase( BaseToolBoxTestCase ): self._init_tool() self._setup_two_versions_in_config( ) self._setup_two_versions() - assert self.toolbox.get_tool_id( "test_tool" ) == "github.com/galaxyproect/example/test_tool/0.1" - assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.1" ) == "github.com/galaxyproect/example/test_tool/0.1" - assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.2" ) == "github.com/galaxyproect/example/test_tool/0.2" - assert self.toolbox.get_tool_id( "github.com/galaxyproect/example/test_tool/0.3" ) is None + assert self.toolbox.get_tool_id( "test_tool" ) == "github.com/galaxyproject/example/test_tool/0.1" + assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.1" ) == "github.com/galaxyproject/example/test_tool/0.1" + assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.2" ) == "github.com/galaxyproject/example/test_tool/0.2" + assert self.toolbox.get_tool_id( "github.com/galaxyproject/example/test_tool/0.3" ) is None def test_tool_dir( self ): self._init_tool() @@ -285,14 +285,14 @@ class ToolBoxTestCase( BaseToolBoxTestCase ): # Verify lineage_ids on both tools is correctly ordered. for version in ["0.1", "0.2"]: - guid = "github.com/galaxyproect/example/test_tool/" + version + guid = "github.com/galaxyproject/example/test_tool/" + version lineage_ids = self.toolbox.get_tool( guid ).lineage_ids - assert lineage_ids[ 0 ] == "github.com/galaxyproect/example/test_tool/0.1" - assert lineage_ids[ 1 ] == "github.com/galaxyproect/example/test_tool/0.2" + assert lineage_ids[ 0 ] == "github.com/galaxyproject/example/test_tool/0.1" + assert lineage_ids[ 1 ] == "github.com/galaxyproject/example/test_tool/0.2" # Test tool_version attribute. - assert self.toolbox.get_tool( "test_tool", tool_version="0.1" ).guid == "github.com/galaxyproect/example/test_tool/0.1" - assert self.toolbox.get_tool( "test_tool", tool_version="0.2" ).guid == "github.com/galaxyproect/example/test_tool/0.2" + assert self.toolbox.get_tool( "test_tool", tool_version="0.1" ).guid == "github.com/galaxyproject/example/test_tool/0.1" + assert self.toolbox.get_tool( "test_tool", tool_version="0.2" ).guid == "github.com/galaxyproject/example/test_tool/0.2" def __remove_itp( self ): os.remove( os.path)