mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-05-24 23:28:32 +08:00
fix: fix API tool integration test (#19187)
This commit is contained in:
parent
1ca6dbcdc8
commit
bb1d1dc263
3
.github/workflows/api-tests.yml
vendored
3
.github/workflows/api-tests.yml
vendored
@ -88,3 +88,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run Workflow
|
- name: Run Workflow
|
||||||
run: uv run --project api bash dev/pytest/pytest_workflow.sh
|
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
|
||||||
|
@ -5,6 +5,8 @@ import httpx
|
|||||||
import pytest
|
import pytest
|
||||||
from _pytest.monkeypatch import MonkeyPatch
|
from _pytest.monkeypatch import MonkeyPatch
|
||||||
|
|
||||||
|
from core.helper import ssrf_proxy
|
||||||
|
|
||||||
|
|
||||||
class MockedHttp:
|
class MockedHttp:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -29,6 +31,6 @@ class MockedHttp:
|
|||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def setup_http_mock(request, monkeypatch: MonkeyPatch):
|
def setup_http_mock(request, monkeypatch: MonkeyPatch):
|
||||||
monkeypatch.setattr(httpx, "request", MockedHttp.httpx_request)
|
monkeypatch.setattr(ssrf_proxy, "make_request", MockedHttp.httpx_request)
|
||||||
yield
|
yield
|
||||||
monkeypatch.undo()
|
monkeypatch.undo()
|
||||||
|
@ -34,10 +34,11 @@ parameters = {
|
|||||||
def test_api_tool(setup_http_mock):
|
def test_api_tool(setup_http_mock):
|
||||||
tool = ApiTool(
|
tool = ApiTool(
|
||||||
entity=ToolEntity(
|
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),
|
api_bundle=ApiToolBundle(**tool_bundle),
|
||||||
runtime=ToolRuntime(tenant_id="", credentials={"auth_type": "none"}),
|
runtime=ToolRuntime(tenant_id="", credentials={"auth_type": "none"}),
|
||||||
|
provider_id="test_tool",
|
||||||
)
|
)
|
||||||
headers = tool.assembling_request(parameters)
|
headers = tool.assembling_request(parameters)
|
||||||
response = tool.do_http_request(tool.api_bundle.server_url, tool.api_bundle.method, headers, parameters)
|
response = tool.do_http_request(tool.api_bundle.server_url, tool.api_bundle.method, headers, parameters)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
pytest api/tests/integration_tests/tools/test_all_provider.py
|
pytest api/tests/integration_tests/tools
|
||||||
|
Loading…
x
Reference in New Issue
Block a user