|
1 | | -from unittest.mock import patch |
| 1 | +from unittest.mock import patch, MagicMock |
2 | 2 | import sys |
3 | 3 | import os |
4 | 4 |
|
5 | 5 | # Add path for correct imports |
6 | 6 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../../backend")) |
7 | 7 |
|
8 | | -# Mock dependencies before importing the actual app |
9 | | -with patch('utils.auth_utils.get_current_user_id') as mock_get_user_id, \ |
10 | | - patch('services.tool_configuration_service.list_all_tools') as mock_list_all_tools, \ |
11 | | - patch('services.tool_configuration_service.search_tool_info_impl') as mock_search_tool_info, \ |
12 | | - patch('services.tool_configuration_service.update_tool_info_impl') as mock_update_tool_info, \ |
13 | | - patch('services.tool_configuration_service.update_tool_list') as mock_update_tool_list: |
14 | | - |
| 8 | +# Mock boto3 to avoid dependency issues |
| 9 | +sys.modules['boto3'] = MagicMock() |
| 10 | + |
| 11 | +# Import exception classes |
| 12 | +from consts.exceptions import MCPConnectionError |
| 13 | + |
| 14 | +# Mock dependencies before importing the actual app - using the same pattern as test_remote_mcp_app.py |
| 15 | +with patch('database.client.MinioClient', MagicMock()): |
15 | 16 | import pytest |
16 | 17 | from fastapi.testclient import TestClient |
17 | 18 | from http import HTTPStatus |
18 | 19 |
|
19 | | - # Import exception classes |
20 | | - from consts.exceptions import MCPConnectionError |
21 | | - |
22 | 20 | # Create a test client with a fresh FastAPI app |
23 | 21 | from apps.tool_config_app import router |
24 | 22 | from fastapi import FastAPI |
25 | 23 |
|
26 | 24 | # Patch exception classes to ensure tests use correct exceptions |
27 | 25 | import apps.tool_config_app as tool_config_app |
28 | 26 | tool_config_app.MCPConnectionError = MCPConnectionError |
29 | | - |
| 27 | + |
30 | 28 | app = FastAPI() |
31 | 29 | app.include_router(router) |
32 | 30 | client = TestClient(app) |
|
0 commit comments