Unverified Commit 5f373733 authored by Marius van den Beek's avatar Marius van den Beek Committed by GitHub
Browse files

Merge pull request #12308 from mvdbeek/more_fixes_ts_update

[21.01] Fix test_repository_update
parents ba10688e cb8d157f
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -26,10 +26,12 @@ class TestRepositoryInstallIntegrationTestCase(integration_util.IntegrationTestC

    def setUp(self):
        super().setUp()
        self.setup_shed_config()
        self.dataset_populator = DatasetPopulator(self.galaxy_interactor)

    def tearDown(self):
        self.reset_shed_tools()
        return super().tearDown()

    def test_repository_installation(self):
        """
@@ -60,11 +62,12 @@ class TestRepositoryInstallIntegrationTestCase(integration_util.IntegrationTestC
    def test_repository_update(self):
        response = self._install_repository(revision=REVISION_4, version="0.0.3")[0]
        assert int(response['ctx_rev']) >= 4
        latest_revision = response['changeset_revision']
        repo_response = self._get("/api/tool_shed_repositories/%s" % response['id']).json()
        assert repo_response['tool_shed_status']['revision_update'] == 'False'  # that should really be a boolean
        # now checkout revision 3 and attempt an update
        path_components = [
            self._app.config.shed_tools_dir,
            os.path.dirname(self._app.config.shed_tool_config_file),
            'toolshed.g2.bx.psu.edu',
            'repos',
            REPO.owner,
@@ -73,25 +76,25 @@ class TestRepositoryInstallIntegrationTestCase(integration_util.IntegrationTestC
            REPO.name
        ]
        revision_3_path = os.path.join(*path_components[:6])
        revision_4_path = os.path.join(*path_components[:5] + [REVISION_4])
        latest_revision_path = os.path.join(*path_components[:5] + [latest_revision])
        repository_path = os.path.join(*path_components)
        # Move repo to location expected before minor update
        os.rename(revision_4_path, revision_3_path)
        os.rename(latest_revision_path, revision_3_path)
        # Checkout revision 3
        hg_util.update_repository(repository_path, ctx_rev='3')
        # change repo to revision 3 in database
        model = self._app.install_model
        tsr = model.context.query(model.ToolShedRepository).first()
        assert tsr.name == REPO.name
        assert tsr.changeset_revision == REVISION_4
        assert tsr.ctx_rev == '4'
        assert tsr.changeset_revision == latest_revision
        assert int(tsr.ctx_rev) >= 4
        tsr.ctx_rev = '3'
        tsr.installed_changeset_revision = REVISION_3
        tsr.changeset_revision = REVISION_3
        model.context.flush()
        # update shed_tool_conf.xml to look like revision 3 was the installed_changeset_revision
        with open(self._app.config.shed_tool_config_file) as shed_config:
            shed_text = shed_config.read().replace(REVISION_4, REVISION_3)
            shed_text = shed_config.read().replace(latest_revision, REVISION_3)
        with open(self._app.config.shed_tool_config_file, 'w') as shed_config:
            shed_config.write(shed_text)
        self._get(
@@ -104,9 +107,9 @@ class TestRepositoryInstallIntegrationTestCase(integration_util.IntegrationTestC
        assert repo_response['tool_shed_status']['revision_update'] == 'True'
        assert repo_response['changeset_revision'] == REVISION_3
        assert repo_response['ctx_rev'] == '3'
        # now install revision 4 (a.k.a a minor update)
        # now install revision 4 (or newer) (a.k.a a minor update)
        response = self._install_repository(revision=REVISION_4, version="0.0.3", verify_tool_absent=False)[0]
        assert response['changeset_revision'] == REVISION_4
        assert response['changeset_revision'] == latest_revision
        assert response['installed_changeset_revision'] == REVISION_3
        # should be 4 or newer
        assert int(response['ctx_rev']) >= 4
+5 −1
Original line number Diff line number Diff line
@@ -59,13 +59,17 @@ class UsesShed:
        config["conda_auto_install"] = True
        config["conda_prefix"] = os.environ.get('GALAXY_TEST_CONDA_PREFIX') or os.path.join(cls.conda_tmp_prefix, 'conda')

    def reset_shed_tools(self):
    def setup_shed_config(self):
        shutil.rmtree(self._app.config.shed_tools_dir, ignore_errors=True)
        os.makedirs(self._app.config.shed_tools_dir)
        self._app.config.shed_tools_dir = self.shed_tools_dir
        with open(self._app.config.shed_tool_config_file, "w") as tool_conf_file:
            tool_conf_file.write(SHED_TOOL_CONF.substitute(shed_tools_path=self._app.config.shed_tools_dir))
        # deleting the containing folder doesn't trigger a toolbox reload, so signal it now and wait until it's done
        self._app.queue_worker.send_control_task('reload_toolbox', get_response=True)

    def reset_shed_tools(self):
        self.setup_shed_config()
        model = self._app.install_model
        models_to_delete = [
            model.RepositoryRepositoryDependencyAssociation,