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

Merge pull request #20399 from dannon/fix-toolshed-tool-icons

[25.0] Fix toolshed-installed tool icons
parents 86ecd965 7ee1d3c4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -118,7 +118,7 @@ function openInteractiveTool(toolId: string) {
                        <div class="tool-icon mr-2">
                            <img
                                v-if="tool.icon"
                                :src="getAppRoot() + 'api/tools/' + tool.id + '/icon'"
                                :src="getAppRoot() + 'api/tools/' + encodeURIComponent(tool.id) + '/icon'"
                                alt="tool icon" />
                            <FontAwesomeIcon v-else :icon="faTools" size="2x" />
                        </div>
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ class FetchTools:
        return self.service.create_fetch(trans, payload, files)

    @router.get(
        "/api/tools/{tool_id}/icon",
        "/api/tools/{tool_id:path}/icon",
        summary="Get the icon image associated with a tool",
        response_class=PNGIconResponse,
        responses={
+14 −0
Original line number Diff line number Diff line
@@ -257,6 +257,20 @@ class TestToolsApi(ApiTestCase, TestsTools):
        assert output["label"] == "Duplicate List"
        assert output["inherit_format"] is True

    def test_tool_icon_endpoint_with_simple_id(self):
        response = self._get("tools/simple_tool_id/icon")
        self._assert_status_code_is(response, 404)

    def test_tool_icon_endpoint_with_toolshed_id(self):
        # Test complex toolshed tool ID with slashes
        toolshed_tool_id = "toolshed.g2.bx.psu.edu/repos/devteam/fastqc/fastqc/0.74+galaxy0"
        response = self._get(f"tools/{toolshed_tool_id}/icon")
        # We expect either 200 (if tool is installed and has icon) or 404 (if
        # not found), but this tests the routing either way.
        assert response.status_code in [200, 404]
        if response.status_code == 200:
            assert response.headers["Content-Type"] == "image/png"

    @skip_without_tool("test_data_source")
    def test_data_source_build_request(self):
        with self.dataset_populator.test_history() as history_id: