fix: fix API tool integration test (#19187)

This commit is contained in:
Hao Cheng 2025-05-01 08:49:43 +02:00 committed by GitHub
parent 1ca6dbcdc8
commit bb1d1dc263
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 3 deletions

View File

@ -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

View File

@ -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()

View File

@ -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)

View File

@ -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