mirror of
https://github.com/langgenius/dify.git
synced 2026-05-03 08:58:09 +08:00
fix: update core.file imports to core.workflow.file after merge
The File class and related modules were moved from core.file to core.workflow.file in the sandboxed-agent branch. This commit updates all remaining references including test mock/patch paths, Switch component defaultValue→value changes, and account setting tab constant updates. Made-with: Cursor
This commit is contained in:
@ -365,7 +365,7 @@ class TestOrganizeUserQuery:
|
||||
|
||||
def test_query_with_files(self, mock_runner):
|
||||
"""Test organizing a query with files."""
|
||||
from core.file.models import File
|
||||
from core.workflow.file.models import File
|
||||
|
||||
mock_file = MagicMock(spec=File)
|
||||
mock_runner.files = [mock_file]
|
||||
|
||||
@ -2,8 +2,8 @@
|
||||
|
||||
from unittest.mock import patch
|
||||
|
||||
from core.file import File, FileTransferMethod, FileType
|
||||
from core.file.file_manager import (
|
||||
from core.workflow.file import File, FileTransferMethod, FileType
|
||||
from core.workflow.file.file_manager import (
|
||||
_encode_file_ref,
|
||||
restore_multimodal_content,
|
||||
to_prompt_message_content,
|
||||
@ -51,8 +51,8 @@ class TestEncodeFileRef:
|
||||
class TestToPromptMessageContent:
|
||||
"""Tests for to_prompt_message_content function with file_ref field."""
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._get_encoded_string")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._get_encoded_string")
|
||||
def test_includes_file_ref(self, mock_get_encoded, mock_config):
|
||||
"""Generated content should include file_ref field."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "base64"
|
||||
@ -120,9 +120,9 @@ class TestRestoreMultimodalContent:
|
||||
|
||||
assert result.url == "https://example.com/image.png"
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._build_file_from_ref")
|
||||
@patch("core.file.file_manager._to_url")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._build_file_from_ref")
|
||||
@patch("core.workflow.file.file_manager._to_url")
|
||||
def test_restores_url_from_file_ref(self, mock_to_url, mock_build_file, mock_config):
|
||||
"""Content should be restored from file_ref when url is empty (url mode)."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "url"
|
||||
@ -143,9 +143,9 @@ class TestRestoreMultimodalContent:
|
||||
assert result.url == "https://restored-url.com/image.png"
|
||||
mock_build_file.assert_called_once()
|
||||
|
||||
@patch("core.file.file_manager.dify_config")
|
||||
@patch("core.file.file_manager._build_file_from_ref")
|
||||
@patch("core.file.file_manager._get_encoded_string")
|
||||
@patch("core.workflow.file.file_manager.dify_config")
|
||||
@patch("core.workflow.file.file_manager._build_file_from_ref")
|
||||
@patch("core.workflow.file.file_manager._get_encoded_string")
|
||||
def test_restores_base64_from_file_ref(self, mock_get_encoded, mock_build_file, mock_config):
|
||||
"""Content should be restored as base64 when in base64 mode."""
|
||||
mock_config.MULTIMODAL_SEND_FORMAT = "base64"
|
||||
|
||||
@ -4,7 +4,7 @@ Unit tests for sandbox file path detection and conversion.
|
||||
|
||||
import pytest
|
||||
|
||||
from core.file import File, FileTransferMethod, FileType
|
||||
from core.workflow.file import File, FileTransferMethod, FileType
|
||||
from core.llm_generator.output_parser.file_ref import (
|
||||
FILE_PATH_DESCRIPTION_SUFFIX,
|
||||
FILE_PATH_FORMAT,
|
||||
|
||||
@ -318,7 +318,7 @@ class TestBuildContext:
|
||||
class TestRestoreMultimodalContentInMessages:
|
||||
"""Tests for restore_multimodal_content_in_messages function."""
|
||||
|
||||
@patch("core.file.file_manager.restore_multimodal_content")
|
||||
@patch("core.workflow.file.file_manager.restore_multimodal_content")
|
||||
def test_restores_multimodal_content(self, mock_restore):
|
||||
"""Should restore multimodal content in messages."""
|
||||
# Setup mock
|
||||
|
||||
@ -109,9 +109,9 @@ def test_stream_llm_events_no_reasoning_results_in_empty_sequence():
|
||||
|
||||
|
||||
def test_serialize_tool_call_strips_files_to_ids():
|
||||
file_cls = pytest.importorskip("core.file").File
|
||||
file_type = pytest.importorskip("core.file.enums").FileType
|
||||
transfer_method = pytest.importorskip("core.file.enums").FileTransferMethod
|
||||
file_cls = pytest.importorskip("core.workflow.file").File
|
||||
file_type = pytest.importorskip("core.workflow.file.enums").FileType
|
||||
transfer_method = pytest.importorskip("core.workflow.file.enums").FileTransferMethod
|
||||
|
||||
file_with_id = file_cls(
|
||||
id="f1",
|
||||
|
||||
Reference in New Issue
Block a user