[autofix.ci] apply automated fixes

This commit is contained in:
autofix-ci[bot] 2025-12-11 01:35:31 +00:00 committed by GitHub
parent 0219d41a1c
commit c069d7a1f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 73 additions and 95 deletions

View File

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