commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/29ed5db57e42/ Changeset: 29ed5db57e42 User: jmchilton Date: 2014-12-24 05:42:54+00:00 Summary: Breakup big remove method in tool_panel_manager.py to ease testing. Separate out logic for dealing with toolbox from logic for dealing repository metadata in the database. Affected #: 2 files diff -r 17f4ab6dc1ff388f1e58e72b886cfa792e3b131c -r 29ed5db57e4247653a9530540180025de8e93f5d lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py --- a/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py +++ b/lib/galaxy/webapps/galaxy/controllers/admin_toolshed.py @@ -249,9 +249,9 @@ if tool_shed_repository.includes_tools_for_display_in_tool_panel: # Handle tool panel alterations. tpm = tool_panel_manager.ToolPanelManager( trans.app ) - tpm.remove_from_tool_panel( tool_shed_repository, - shed_tool_conf, - uninstall=remove_from_disk_checked ) + tpm.remove_repository_contents( tool_shed_repository, + shed_tool_conf, + uninstall=remove_from_disk_checked ) if tool_shed_repository.includes_data_managers: dmh = data_manager.DataManagerHandler( trans.app ) dmh.remove_from_data_manager( tool_shed_repository ) diff -r 17f4ab6dc1ff388f1e58e72b886cfa792e3b131c -r 29ed5db57e4247653a9530540180025de8e93f5d lib/tool_shed/galaxy_install/tools/tool_panel_manager.py --- a/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py +++ b/lib/tool_shed/galaxy_install/tools/tool_panel_manager.py @@ -427,7 +427,7 @@ # Persist the altered in-memory version of the tool config. self.config_elems_to_xml_file( config_elems, shed_tool_conf, tool_path ) - def remove_from_tool_panel( self, repository, shed_tool_conf, uninstall ): + def remove_repository_contents( self, repository, shed_tool_conf, uninstall ): """ A tool shed repository is being deactivated or uninstalled, so handle tool panel alterations accordingly. @@ -442,6 +442,9 @@ # Create a list of guids for all tools that will be removed from the in-memory tool panel # and config file on disk. guids_to_remove = [ k for k in tool_panel_dict.keys() ] + self.remove_guids( guids_to_remove, shed_tool_conf, uninstall ) + + def remove_guids( self, guids_to_remove, shed_tool_conf, uninstall ): # Remove the tools from the toolbox's tools_by_id dictionary. for guid_to_remove in guids_to_remove: if guid_to_remove in self.app.toolbox.tools_by_id: https://bitbucket.org/galaxy/galaxy-central/commits/179199007ec9/ Changeset: 179199007ec9 User: jmchilton Date: 2014-12-24 05:42:54+00:00 Summary: Unit test coverage for removing stuff from the toolbox. Covers cases for tools inside and outside of sections and both deactivation versus uninstallation. Affected #: 2 files diff -r 29ed5db57e4247653a9530540180025de8e93f5d -r 179199007ec93cdfa45b200e9a27486035ff2477 test/unit/tool_shed_unit_tests/test_tool_panel_manager.py --- a/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py +++ b/test/unit/tool_shed_unit_tests/test_tool_panel_manager.py @@ -12,7 +12,7 @@ self._init_tool() self._add_config( """<toolbox><section id="tid" name="test"><tool file="tool.xml" /></section></toolbox>""" ) toolbox = self.toolbox - tpm = tool_panel_manager.ToolPanelManager( self.app ) + tpm = self.tpm # Test fetch existing section by id. section_id, section = tpm.handle_tool_panel_section( toolbox, tool_panel_section_id="tid" ) assert section_id == "tid" @@ -47,7 +47,7 @@ ) ] _, section = self.toolbox.get_or_create_section("tid1") - tpm = tool_panel_manager.ToolPanelManager( self.app ) + tpm = self.tpm tool_panel_dict = tpm.generate_tool_panel_dict_for_new_install( tool_dicts=new_tools, tool_section=section, @@ -61,6 +61,77 @@ shed_tool_conf="tool_conf.xml", tool_panel_dict=tool_panel_dict, ) + self._verify_tool_confs() + + def test_deactivate_in_section( self ): + 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() + self._verify_tool_confs() + + self._remove_guids( ["github.com/galaxyproect/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 ) + assert not all_versions + + # Check that tool panel has reverted to old value... + section = self.toolbox.tool_panel["tid"] + assert len(section.elems) == 0 + + def test_uninstall_in_section( self ): + 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() + 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() + 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() + self._verify_tool_confs() + + def _setup_two_versions_remove_one( self, section, uninstall ): + self._init_tool() + 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 ) + + def _verify_version_2_removed_from_panel( self, section=True ): + # Check that test_tool now only has one version... + all_versions = self.toolbox.get_tool( "test_tool", get_all_versions=True ) + assert len( all_versions ) == 1 + + # Check that tool panel has reverted to old value... + 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 "github.com/galaxyproect/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 + + def _remove_guids( self, guids, uninstall, shed_tool_conf="tool_conf.xml" ): + self.tpm.remove_guids( + guids_to_remove=guids, + shed_tool_conf=shed_tool_conf, + uninstall=uninstall, + ) + + def _verify_tool_confs( self ): self._assert_valid_xml( self.integerated_tool_panel_path ) self._assert_valid_xml( os.path.join( self.test_directory, "tool_conf.xml" ) ) @@ -71,3 +142,7 @@ message_template = "file %s does not contain valid XML, content %s" message = message_template % ( filename, open( filename, "r" ).read() ) raise AssertionError( message ) + + @property + def tpm( self ): + return tool_panel_manager.ToolPanelManager( self.app ) diff -r 29ed5db57e4247653a9530540180025de8e93f5d -r 179199007ec93cdfa45b200e9a27486035ff2477 test/unit/tools/test_toolbox.py --- a/test/unit/tools/test_toolbox.py +++ b/test/unit/tools/test_toolbox.py @@ -91,6 +91,27 @@ self.app.install_model.context.add( version_association ) self.app.install_model.context.flush( ) + def _setup_two_versions_in_config( self, section=False ): + if section: + template = """<toolbox tool_path="%s"> +<section id="tid" name="TID" version=""> + %s +</section> +<section id="tid" name="TID" version=""> + %s +</section> +</toolbox>""" + else: + template = """<toolbox tool_path="%s"> +<section id="tid" name="TID" version=""> + %s +</section> +<section id="tid" name="TID" version=""> + %s +</section> +</toolbox>""" + self._add_config( template % (self.test_directory, CONFIG_TEST_TOOL_VERSION_1, CONFIG_TEST_TOOL_VERSION_2 ) ) + def _add_config( self, xml, name="tool_conf.xml" ): path = self._tool_conf_path( name=name ) with open( path, "w" ) as f: @@ -133,14 +154,7 @@ def test_groups_tools_in_section( self ): self._init_tool() - self._add_config( """<toolbox tool_path="%s"> -<section id="tid" name="TID" version=""> - %s -</section> -<section id="tid" name="TID" version=""> - %s -</section> -</toolbox>""" % (self.test_directory, CONFIG_TEST_TOOL_VERSION_1, CONFIG_TEST_TOOL_VERSION_2 ) ) + self._setup_two_versions_in_config( section=True ) self._setup_two_versions() self.toolbox self.__verify_two_test_tools( ) @@ -152,11 +166,7 @@ def test_group_tools_out_of_section( self ): self._init_tool() - self._add_config( """<toolbox tool_path="%s"> -%s -%s -</toolbox>""" % (self.test_directory, CONFIG_TEST_TOOL_VERSION_1, CONFIG_TEST_TOOL_VERSION_2 ) ) - + self._setup_two_versions_in_config( section=False ) self._setup_two_versions() self.__verify_two_test_tools( ) Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org