Bugfix for 44dfa6f and typos in unit tests that caused it to go undetected.

This commit is contained in:
John Chilton
2014-12-28 23:25:56 -05:00
parent 280dc18442
commit 7dca5cb1f6
3 changed files with 30 additions and 27 deletions
@@ -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:
@@ -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(
+14 -14
View File
@@ -10,12 +10,12 @@ import tools_support
CONFIG_TEST_TOOL_VERSION_TEMPLATE = string.Template(
""" <tool file="tool.xml" guid="github.com/galaxyproect/example/test_tool/0.${version}">
""" <tool file="tool.xml" guid="github.com/galaxyproject/example/test_tool/0.${version}">
<tool_shed>github.com</tool_shed>
<repository_name>example</repository_name>
<repository_owner>galaxyproject</repository_owner>
<installed_changeset_revision>${version}</installed_changeset_revision>
<id>github.com/galaxyproect/example/test_tool/0.${version}</id>
<id>github.com/galaxyproject/example/test_tool/0.${version}</id>
<version>0.${version}</version>
</tool>
"""
@@ -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)