mirror of https://github.com/langgenius/dify.git
[autofix.ci] apply automated fixes
This commit is contained in:
parent
0219d41a1c
commit
c069d7a1f8
|
|
@ -25,7 +25,6 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
import pytest
|
||||
from flask import Flask, Response
|
||||
from pydantic import ValidationError
|
||||
|
||||
from controllers.console.app.mcp_server import AppMCPServerStatus
|
||||
from controllers.mcp.mcp import MCPAppApi, MCPRequestError
|
||||
|
|
@ -131,9 +130,7 @@ class TestMCPAppApi:
|
|||
session = MagicMock()
|
||||
return session
|
||||
|
||||
def test_handle_initialize_request_success(
|
||||
self, app, mock_mcp_server, mock_app
|
||||
):
|
||||
def test_handle_initialize_request_success(self, app, mock_mcp_server, mock_app):
|
||||
"""Test successful handling of initialize request.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -223,9 +220,7 @@ class TestMCPAppApi:
|
|||
assert call_args[0][1].root.method == "initialize" # request parameter
|
||||
assert call_args[0][4] == request_id # request_id parameter
|
||||
|
||||
def test_handle_list_tools_request_success(
|
||||
self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session
|
||||
):
|
||||
def test_handle_list_tools_request_success(self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session):
|
||||
"""Test successful handling of tools/list request.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -317,9 +312,7 @@ class TestMCPAppApi:
|
|||
assert result.status_code == 200
|
||||
mock_handle_request.assert_called_once()
|
||||
|
||||
def test_handle_notification_success(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_handle_notification_success(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test successful handling of notification (notifications/initialized).
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -375,9 +368,7 @@ class TestMCPAppApi:
|
|||
assert result.status_code == 202 # Accepted status for notifications
|
||||
assert result.data == b"" # No response body for notifications
|
||||
|
||||
def test_handle_invalid_notification_method(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_handle_invalid_notification_method(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test handling of invalid notification method.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -721,9 +712,7 @@ class TestMCPAppApi:
|
|||
assert exc_info.value.error_code == mcp_types.INVALID_REQUEST
|
||||
assert "Request ID is required" in exc_info.value.message
|
||||
|
||||
def test_user_input_form_extraction_workflow_mode(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_user_input_form_extraction_workflow_mode(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test user input form extraction for workflow mode apps.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -797,9 +786,7 @@ class TestMCPAppApi:
|
|||
# Verify that workflow.user_input_form was called
|
||||
mock_app.workflow.user_input_form.assert_called_once_with(to_old_structure=True)
|
||||
|
||||
def test_user_input_form_extraction_chat_mode(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_user_input_form_extraction_chat_mode(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test user input form extraction for chat mode apps.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -1019,9 +1006,7 @@ class TestMCPAppApi:
|
|||
assert exc_info.value.error_code == mcp_types.INVALID_REQUEST
|
||||
assert "App is unavailable" in exc_info.value.message
|
||||
|
||||
def test_end_user_creation_on_initialize(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_end_user_creation_on_initialize(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test end user creation when initialize request is received.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -1139,9 +1124,7 @@ class TestMCPAppApi:
|
|||
assert created_user.name == "TestClient@2.0.0"
|
||||
assert created_user.session_id == mock_mcp_server.id
|
||||
|
||||
def test_invalid_user_input_form_validation_error(
|
||||
self, app, mock_mcp_server, mock_app, mock_db_session
|
||||
):
|
||||
def test_invalid_user_input_form_validation_error(self, app, mock_mcp_server, mock_app, mock_db_session):
|
||||
"""Test error handling for invalid user input form structure.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -1206,9 +1189,7 @@ class TestMCPAppApi:
|
|||
assert exc_info.value.error_code == mcp_types.INVALID_PARAMS
|
||||
assert "Invalid user_input_form" in exc_info.value.message
|
||||
|
||||
def test_call_tool_request_processing(
|
||||
self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session
|
||||
):
|
||||
def test_call_tool_request_processing(self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session):
|
||||
"""Test successful processing of tools/call request.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -1300,9 +1281,7 @@ class TestMCPAppApi:
|
|||
assert call_args[0][4] == mock_end_user # end_user parameter
|
||||
assert call_args[0][1].root.method == "tools/call" # request method
|
||||
|
||||
def test_ping_request_processing(
|
||||
self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session
|
||||
):
|
||||
def test_ping_request_processing(self, app, mock_mcp_server, mock_app, mock_end_user, mock_db_session):
|
||||
"""Test successful processing of ping request.
|
||||
|
||||
This test verifies that:
|
||||
|
|
@ -1374,4 +1353,3 @@ class TestMCPAppApi:
|
|||
assert isinstance(result, Response)
|
||||
assert result.status_code == 200
|
||||
mock_handle_request.assert_called_once()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue