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.

test: migrate custom tool provider ORM model to real entity (#40653)

Asuka Minato4e0d7f7f9b3f
diff --git a/api/tests/unit_tests/core/tools/test_custom_tool_provider.py b/api/tests/unit_tests/core/tools/test_custom_tool_provider.py
index 78c5c071747..cd299047da3 100644
--- a/api/tests/unit_tests/core/tools/test_custom_tool_provider.py
+++ b/api/tests/unit_tests/core/tools/test_custom_tool_provider.py
@@ -4,8 +4,6 @@ from __future__ import annotations
import json
from dataclasses import dataclass
-from types import SimpleNamespace
-from typing import cast
from unittest.mock import MagicMock
from uuid import uuid4
@@ -26,8 +24,8 @@ class _Database:
session: Session
-def _db_provider() -> ApiToolProvider:
- bundle = ApiToolBundle(
+def _tool_bundle() -> ApiToolBundle:
+ return ApiToolBundle(
server_url="https://api.example.com/items",
method="GET",
summary="List items",
@@ -36,22 +34,26 @@ def _db_provider() -> ApiToolProvider:
author="author",
openapi={"parameters": []},
)
- return cast(
- ApiToolProvider,
- SimpleNamespace(
- id="provider-id",
- tenant_id="tenant-1",
- name="provider-a",
- description="desc",
- icon="icon.svg",
- user=MagicMock(return_value=SimpleNamespace(name="Alice")),
- tools=[bundle],
- ),
+
+
+def _db_provider() -> ApiToolProvider:
+ provider = ApiToolProvider(
+ name="provider-a",
+ icon="icon.svg",
+ schema="{}",
+ schema_type_str=ApiProviderSchemaType.OPENAPI,
+ user_id="",
+ tenant_id="tenant-1",
+ description="desc",
+ tools_str=json.dumps([_tool_bundle().model_dump(mode="json")]),
+ credentials_str='{"auth_type":"none"}',
)
+ provider.id = "provider-id"
+ return provider
def _persist_provider(session: Session, *, tenant_id: str, name: str = "provider-a") -> ApiToolProvider:
- bundle = _db_provider().tools[0]
+ bundle = _tool_bundle()
provider = ApiToolProvider(
name=name,
icon="icon.svg",