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 workflow tool-file ORM model to real entity (#40658)

Asuka Minato6ea89dc7cb18
diff --git a/api/tests/unit_tests/core/workflow/test_node_runtime.py b/api/tests/unit_tests/core/workflow/test_node_runtime.py
index 39cfa96c243..3bc5c01ffb3 100644
--- a/api/tests/unit_tests/core/workflow/test_node_runtime.py
+++ b/api/tests/unit_tests/core/workflow/test_node_runtime.py
@@ -53,6 +53,7 @@ from models.base import TypeBase
from models.dataset import SegmentAttachmentBinding
from models.enums import CreatorUserRole
from models.model import StorageType, UploadFile
+from models.tools import ToolFile
from tests.workflow_test_utils import build_test_run_context
@@ -715,7 +716,17 @@ def test_dify_retriever_attachment_loader_skips_segment_rejected_by_checker(
def test_dify_tool_file_manager_resolves_conversation_id_for_tool_files(monkeypatch: pytest.MonkeyPatch) -> None:
- create_file_by_raw = MagicMock(return_value=SimpleNamespace(id="tool-file-id"))
+ tool_file = ToolFile(
+ user_id="user-id",
+ tenant_id="tenant-id",
+ conversation_id="conversation-id",
+ file_key="tools/tenant-id/tool-file-id.png",
+ mimetype="image/png",
+ name="diagram.png",
+ size=len(b"file-bytes"),
+ )
+ tool_file.id = "tool-file-id"
+ create_file_by_raw = MagicMock(return_value=tool_file)
manager_instance = SimpleNamespace(create_file_by_raw=create_file_by_raw)
monkeypatch.setattr(node_runtime, "ToolFileManager", MagicMock(return_value=manager_instance))
conversation_id_getter = MagicMock(return_value="conversation-id")