Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: fix API tool integration test (#19187)

Hao Chengbb1d1dc263df
diff --git a/.github/workflows/api-tests.yml b/.github/workflows/api-tests.yml
index 02583cda063..f08befefb8e 100644
--- a/.github/workflows/api-tests.yml
+++ b/.github/workflows/api-tests.yml
@@ -88,3 +88,6 @@ jobs:
- name: Run Workflow
run: uv run --project api bash dev/pytest/pytest_workflow.sh
+
+ - name: Run Tool
+ run: uv run --project api bash dev/pytest/pytest_tools.sh
diff --git a/api/tests/integration_tests/tools/__mock/http.py b/api/tests/integration_tests/tools/__mock/http.py
index 42cf87e317a..de9711ab386 100644
--- a/api/tests/integration_tests/tools/__mock/http.py
+++ b/api/tests/integration_tests/tools/__mock/http.py
@@ -5,6 +5,8 @@ import httpx
import pytest
from _pytest.monkeypatch import MonkeyPatch
+from core.helper import ssrf_proxy
+
class MockedHttp:
@staticmethod
@@ -29,6 +31,6 @@ class MockedHttp:
@pytest.fixture
def setup_http_mock(request, monkeypatch: MonkeyPatch):
- monkeypatch.setattr(httpx, "request", MockedHttp.httpx_request)
+ monkeypatch.setattr(ssrf_proxy, "make_request", MockedHttp.httpx_request)
yield
monkeypatch.undo()
diff --git a/api/tests/integration_tests/tools/api_tool/test_api_tool.py b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
index 9acc94e1108..7c1a200c8f0 100644
--- a/api/tests/integration_tests/tools/api_tool/test_api_tool.py
+++ b/api/tests/integration_tests/tools/api_tool/test_api_tool.py
@@ -34,10 +34,11 @@ parameters = {
def test_api_tool(setup_http_mock):
tool = ApiTool(
entity=ToolEntity(
- identity=ToolIdentity(provider="", author="", name="", label=I18nObject()),
+ identity=ToolIdentity(provider="", author="", name="", label=I18nObject(en_US="test tool")),
),
api_bundle=ApiToolBundle(**tool_bundle),
runtime=ToolRuntime(tenant_id="", credentials={"auth_type": "none"}),
+ provider_id="test_tool",
)
headers = tool.assembling_request(parameters)
response = tool.do_http_request(tool.api_bundle.server_url, tool.api_bundle.method, headers, parameters)
diff --git a/dev/pytest/pytest_tools.sh b/dev/pytest/pytest_tools.sh
index 5b1de8b6dd3..0b1a8c98779 100755
--- a/dev/pytest/pytest_tools.sh
+++ b/dev/pytest/pytest_tools.sh
@@ -1,4 +1,4 @@
#!/bin/bash
set -x
-pytest api/tests/integration_tests/tools/test_all_provider.py
+pytest api/tests/integration_tests/tools