mirror of
https://gitee.com/wanwujie/deer-flow
synced 2026-04-18 12:04:45 +08:00
feat: 1. replace black with ruff for fomatting and sort import (#489)
2. use tavily from`langchain-tavily` rather than the older one from `langchain-community` Co-authored-by: Willem Jiang <willem.jiang@gmail.com>
This commit is contained in:
@@ -3,15 +3,16 @@
|
||||
|
||||
import base64
|
||||
import os
|
||||
from unittest.mock import MagicMock, patch, mock_open
|
||||
from unittest.mock import MagicMock, mock_open, patch
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from fastapi import HTTPException
|
||||
from src.server.app import app, _make_event, _astream_workflow_generator
|
||||
from src.config.report_style import ReportStyle
|
||||
from fastapi.testclient import TestClient
|
||||
from langchain_core.messages import AIMessageChunk, ToolMessage
|
||||
from langgraph.types import Command
|
||||
from langchain_core.messages import ToolMessage
|
||||
from langchain_core.messages import AIMessageChunk
|
||||
|
||||
from src.config.report_style import ReportStyle
|
||||
from src.server.app import _astream_workflow_generator, _make_event, app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -333,7 +334,6 @@ class TestMCPEndpoint:
|
||||
def test_mcp_server_metadata_without_enable_configuration(
|
||||
self, mock_load_tools, client
|
||||
):
|
||||
|
||||
request_data = {
|
||||
"transport": "stdio",
|
||||
"command": "test_command",
|
||||
@@ -547,7 +547,6 @@ class TestAstreamWorkflowGenerator:
|
||||
@pytest.mark.asyncio
|
||||
@patch("src.server.app.graph")
|
||||
async def test_astream_workflow_generator_with_interrupt_feedback(self, mock_graph):
|
||||
|
||||
# Mock the async stream
|
||||
async def mock_astream(*args, **kwargs):
|
||||
# Verify that Command is passed as input when interrupt_feedback is provided
|
||||
@@ -620,7 +619,6 @@ class TestAstreamWorkflowGenerator:
|
||||
@pytest.mark.asyncio
|
||||
@patch("src.server.app.graph")
|
||||
async def test_astream_workflow_generator_tool_message(self, mock_graph):
|
||||
|
||||
# Mock tool message
|
||||
mock_tool_message = ToolMessage(content="Tool result", tool_call_id="tool_123")
|
||||
mock_tool_message.id = "msg_456"
|
||||
@@ -659,7 +657,6 @@ class TestAstreamWorkflowGenerator:
|
||||
async def test_astream_workflow_generator_ai_message_with_tool_calls(
|
||||
self, mock_graph
|
||||
):
|
||||
|
||||
# Mock AI message with tool calls
|
||||
mock_ai_message = AIMessageChunk(content="Making tool call")
|
||||
mock_ai_message.id = "msg_789"
|
||||
@@ -701,7 +698,6 @@ class TestAstreamWorkflowGenerator:
|
||||
async def test_astream_workflow_generator_ai_message_with_tool_call_chunks(
|
||||
self, mock_graph
|
||||
):
|
||||
|
||||
# Mock AI message with only tool call chunks
|
||||
mock_ai_message = AIMessageChunk(content="Streaming tool call")
|
||||
mock_ai_message.id = "msg_101"
|
||||
@@ -740,7 +736,6 @@ class TestAstreamWorkflowGenerator:
|
||||
@pytest.mark.asyncio
|
||||
@patch("src.server.app.graph")
|
||||
async def test_astream_workflow_generator_with_finish_reason(self, mock_graph):
|
||||
|
||||
# Mock AI message with finish reason
|
||||
mock_ai_message = AIMessageChunk(content="Complete response")
|
||||
mock_ai_message.id = "msg_finish"
|
||||
@@ -780,7 +775,6 @@ class TestAstreamWorkflowGenerator:
|
||||
@pytest.mark.asyncio
|
||||
@patch("src.server.app.graph")
|
||||
async def test_astream_workflow_generator_config_passed_correctly(self, mock_graph):
|
||||
|
||||
mock_ai_message = AIMessageChunk(content="Test")
|
||||
mock_ai_message.id = "test_id"
|
||||
mock_ai_message.response_metadata = {}
|
||||
|
||||
Reference in New Issue
Block a user