diff --git a/src/tests/backend/auth/test_auth_utils.py b/src/tests/backend/auth/test_auth_utils.py index 0fdc848bf..01eee62e5 100644 --- a/src/tests/backend/auth/test_auth_utils.py +++ b/src/tests/backend/auth/test_auth_utils.py @@ -5,10 +5,8 @@ import pytest import base64 import json -import logging import sys import os -import importlib.util from unittest.mock import patch, MagicMock # Add the source root directory to the Python path for imports diff --git a/src/tests/backend/common/config/test_app_config.py b/src/tests/backend/common/config/test_app_config.py index 95784031b..2652d4532 100644 --- a/src/tests/backend/common/config/test_app_config.py +++ b/src/tests/backend/common/config/test_app_config.py @@ -13,9 +13,6 @@ import os import logging from unittest.mock import patch, MagicMock, AsyncMock -from azure.identity import DefaultAzureCredential, ManagedIdentityCredential -from azure.cosmos import CosmosClient -from azure.ai.projects.aio import AIProjectClient # Add the source root directory to the Python path for imports import sys diff --git a/src/tests/backend/common/database/test_cosmosdb.py b/src/tests/backend/common/database/test_cosmosdb.py index 4a34a5f91..31cfe34ce 100644 --- a/src/tests/backend/common/database/test_cosmosdb.py +++ b/src/tests/backend/common/database/test_cosmosdb.py @@ -4,10 +4,8 @@ import logging import sys import os -from typing import Any, Dict, List, Optional -from unittest.mock import AsyncMock, MagicMock, Mock, patch +from unittest.mock import AsyncMock, Mock, patch import pytest -import uuid # Add the backend directory to the Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend')) diff --git a/src/tests/backend/common/database/test_database_base.py b/src/tests/backend/common/database/test_database_base.py index 9491ed6b8..0eba3ba6f 100644 --- a/src/tests/backend/common/database/test_database_base.py +++ b/src/tests/backend/common/database/test_database_base.py @@ -2,9 +2,9 @@ import sys import os -from abc import ABC, abstractmethod +from abc import ABC from typing import Any, Dict, List, Optional, Type -from unittest.mock import AsyncMock, Mock, patch +from unittest.mock import Mock import pytest # Add the backend directory to the Python path diff --git a/src/tests/backend/common/database/test_database_factory.py b/src/tests/backend/common/database/test_database_factory.py index bb3643322..e58be8672 100644 --- a/src/tests/backend/common/database/test_database_factory.py +++ b/src/tests/backend/common/database/test_database_factory.py @@ -3,8 +3,7 @@ import logging import sys import os -from typing import Optional -from unittest.mock import AsyncMock, Mock, patch, MagicMock +from unittest.mock import AsyncMock, Mock, patch import pytest # Add the backend directory to the Python path diff --git a/src/tests/backend/common/utils/test_event_utils.py b/src/tests/backend/common/utils/test_event_utils.py index 74a23e62e..99613092d 100644 --- a/src/tests/backend/common/utils/test_event_utils.py +++ b/src/tests/backend/common/utils/test_event_utils.py @@ -3,7 +3,7 @@ import logging import sys import os -from unittest.mock import Mock, patch, MagicMock +from unittest.mock import Mock, patch import pytest # Mock external dependencies at module level diff --git a/src/tests/backend/common/utils/test_otlp_tracing.py b/src/tests/backend/common/utils/test_otlp_tracing.py index dbf3ab244..ac7474f1e 100644 --- a/src/tests/backend/common/utils/test_otlp_tracing.py +++ b/src/tests/backend/common/utils/test_otlp_tracing.py @@ -2,7 +2,7 @@ import sys import os -from unittest.mock import Mock, patch, MagicMock, call +from unittest.mock import Mock, patch, call import pytest # Mock external dependencies at module level diff --git a/src/tests/backend/common/utils/test_utils_af.py b/src/tests/backend/common/utils/test_utils_af.py index 815f8c9fd..30307a9f4 100644 --- a/src/tests/backend/common/utils/test_utils_af.py +++ b/src/tests/backend/common/utils/test_utils_af.py @@ -1,10 +1,8 @@ """Unit tests for utils_af module.""" -import logging import sys import os -import uuid -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, patch, AsyncMock import pytest # Add the backend directory to the Python path diff --git a/src/tests/backend/common/utils/test_utils_agents.py b/src/tests/backend/common/utils/test_utils_agents.py index 8f4e80891..dd3833a89 100644 --- a/src/tests/backend/common/utils/test_utils_agents.py +++ b/src/tests/backend/common/utils/test_utils_agents.py @@ -4,7 +4,6 @@ This module tests the utility functions for agent ID generation and database operations. """ -import logging import string import sys import unittest @@ -33,10 +32,8 @@ sys.modules['common.models'] = Mock() sys.modules['common.models.messages_af'] = Mock() -import pytest - from backend.common.database.database_base import DatabaseBase -from backend.common.models.messages_af import CurrentTeamAgent, DataType, TeamConfiguration +from backend.common.models.messages_af import CurrentTeamAgent, TeamConfiguration from backend.common.utils.utils_agents import ( generate_assistant_id, get_database_team_agent_id, diff --git a/src/tests/backend/common/utils/test_utils_date.py b/src/tests/backend/common/utils/test_utils_date.py index 377e51757..4018a4429 100644 --- a/src/tests/backend/common/utils/test_utils_date.py +++ b/src/tests/backend/common/utils/test_utils_date.py @@ -7,16 +7,12 @@ import json import locale -import logging import unittest import sys import os from datetime import datetime -from typing import Optional from unittest.mock import Mock, patch -import pytest - # Add the backend directory to the Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend')) @@ -90,9 +86,6 @@ def mock_parse(date_str): import re as real_re utils_date_module.re = real_re -# Import dateutil.parser after mocking to avoid import errors -from dateutil import parser - class TestFormatDateForUser(unittest.TestCase): """Test cases for format_date_for_user function.""" diff --git a/src/tests/backend/middleware/test_health_check.py b/src/tests/backend/middleware/test_health_check.py index 5cb545b8b..76e88ccd5 100644 --- a/src/tests/backend/middleware/test_health_check.py +++ b/src/tests/backend/middleware/test_health_check.py @@ -1,7 +1,5 @@ """Unit tests for backend.middleware.health_check module.""" -import asyncio -import logging -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, patch, AsyncMock import pytest # Import the module under test diff --git a/src/tests/backend/v4/api/test_router.py b/src/tests/backend/v4/api/test_router.py index 9558a59a4..1d1882d71 100644 --- a/src/tests/backend/v4/api/test_router.py +++ b/src/tests/backend/v4/api/test_router.py @@ -7,7 +7,6 @@ import sys import unittest from unittest.mock import Mock, patch -import asyncio # Set up environment sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', 'backend')) diff --git a/src/tests/backend/v4/callbacks/test_global_debug.py b/src/tests/backend/v4/callbacks/test_global_debug.py index f630b605e..3180cf91e 100644 --- a/src/tests/backend/v4/callbacks/test_global_debug.py +++ b/src/tests/backend/v4/callbacks/test_global_debug.py @@ -1,7 +1,6 @@ """Unit tests for backend.v4.callbacks.global_debug module.""" import sys -from unittest.mock import Mock, patch -import pytest +from unittest.mock import Mock # Mock the dependencies before importing the module under test sys.modules['azure'] = Mock() diff --git a/src/tests/backend/v4/callbacks/test_response_handlers.py b/src/tests/backend/v4/callbacks/test_response_handlers.py index 25ed5601f..a74e9c685 100644 --- a/src/tests/backend/v4/callbacks/test_response_handlers.py +++ b/src/tests/backend/v4/callbacks/test_response_handlers.py @@ -1,11 +1,8 @@ """Unit tests for response_handlers module.""" -import asyncio -import logging import sys import os -import time -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, patch, AsyncMock import pytest # Add the backend directory to the Python path diff --git a/src/tests/backend/v4/common/services/test_base_api_service.py b/src/tests/backend/v4/common/services/test_base_api_service.py index 37a6f7963..5a45837f4 100644 --- a/src/tests/backend/v4/common/services/test_base_api_service.py +++ b/src/tests/backend/v4/common/services/test_base_api_service.py @@ -13,7 +13,6 @@ import sys import importlib.util from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, Optional, Union import aiohttp from aiohttp import ClientTimeout, ClientSession diff --git a/src/tests/backend/v4/common/services/test_foundry_service.py b/src/tests/backend/v4/common/services/test_foundry_service.py index 9b71cd28f..ee6b714e4 100644 --- a/src/tests/backend/v4/common/services/test_foundry_service.py +++ b/src/tests/backend/v4/common/services/test_foundry_service.py @@ -11,13 +11,9 @@ import pytest import os -import re -import logging -import aiohttp import sys -import importlib.util -from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, List +from unittest.mock import patch, MagicMock, AsyncMock +from typing import Any, Dict # Add backend directory to sys.path for imports current_dir = os.path.dirname(os.path.abspath(__file__)) diff --git a/src/tests/backend/v4/common/services/test_mcp_service.py b/src/tests/backend/v4/common/services/test_mcp_service.py index ae0b134e6..04e0844d8 100644 --- a/src/tests/backend/v4/common/services/test_mcp_service.py +++ b/src/tests/backend/v4/common/services/test_mcp_service.py @@ -14,10 +14,8 @@ import sys import asyncio import importlib.util -from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, Optional -import aiohttp -from aiohttp import ClientTimeout, ClientSession, ClientError +from unittest.mock import patch, MagicMock +from aiohttp import ClientError # Add the src directory to sys.path for proper import src_path = os.path.join(os.path.dirname(__file__), '..', '..', '..', '..') diff --git a/src/tests/backend/v4/common/services/test_plan_service.py b/src/tests/backend/v4/common/services/test_plan_service.py index 3c6ccc734..455200af7 100644 --- a/src/tests/backend/v4/common/services/test_plan_service.py +++ b/src/tests/backend/v4/common/services/test_plan_service.py @@ -17,8 +17,8 @@ import json import logging import importlib.util -from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, Optional, List +from unittest.mock import patch, MagicMock, AsyncMock +from typing import Any, List from dataclasses import dataclass # Add the src directory to sys.path for proper import diff --git a/src/tests/backend/v4/common/services/test_team_service.py b/src/tests/backend/v4/common/services/test_team_service.py index c8573fe7b..0fe9d9495 100644 --- a/src/tests/backend/v4/common/services/test_team_service.py +++ b/src/tests/backend/v4/common/services/test_team_service.py @@ -16,13 +16,9 @@ import os import sys import asyncio -import json -import logging import uuid import importlib.util -from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, Optional, List, Tuple -from dataclasses import dataclass +from unittest.mock import patch, MagicMock, AsyncMock from datetime import datetime, timezone # Add the src directory to sys.path for proper import diff --git a/src/tests/backend/v4/magentic_agents/common/test_lifecycle.py b/src/tests/backend/v4/magentic_agents/common/test_lifecycle.py index c3ee233ce..d30b79654 100644 --- a/src/tests/backend/v4/magentic_agents/common/test_lifecycle.py +++ b/src/tests/backend/v4/magentic_agents/common/test_lifecycle.py @@ -2,7 +2,7 @@ import asyncio import logging import sys -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, patch, AsyncMock import pytest # Mock the dependencies before importing the module under test diff --git a/src/tests/backend/v4/magentic_agents/test_foundry_agent.py b/src/tests/backend/v4/magentic_agents/test_foundry_agent.py index 335fc3a33..97da0b31e 100644 --- a/src/tests/backend/v4/magentic_agents/test_foundry_agent.py +++ b/src/tests/backend/v4/magentic_agents/test_foundry_agent.py @@ -1,11 +1,8 @@ """Unit tests for backend.v4.magentic_agents.foundry_agent module.""" -import asyncio -import logging import sys import os -import time -from unittest.mock import Mock, patch, AsyncMock, MagicMock, call +from unittest.mock import Mock, patch, AsyncMock import pytest # Add the backend directory to the Python path diff --git a/src/tests/backend/v4/magentic_agents/test_magentic_agent_factory.py b/src/tests/backend/v4/magentic_agents/test_magentic_agent_factory.py index bfbece0c3..23e370f9c 100644 --- a/src/tests/backend/v4/magentic_agents/test_magentic_agent_factory.py +++ b/src/tests/backend/v4/magentic_agents/test_magentic_agent_factory.py @@ -1,10 +1,8 @@ """Unit tests for backend.v4.magentic_agents.magentic_agent_factory module.""" -import asyncio -import json import logging import sys from types import SimpleNamespace -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, AsyncMock import pytest # Mock the dependencies before importing the module under test diff --git a/src/tests/backend/v4/magentic_agents/test_proxy_agent.py b/src/tests/backend/v4/magentic_agents/test_proxy_agent.py index 2081f35b0..ca734df44 100644 --- a/src/tests/backend/v4/magentic_agents/test_proxy_agent.py +++ b/src/tests/backend/v4/magentic_agents/test_proxy_agent.py @@ -4,7 +4,7 @@ import sys import time import uuid -from unittest.mock import Mock, patch, AsyncMock, MagicMock +from unittest.mock import Mock, patch, AsyncMock import pytest # Mock the dependencies before importing the module under test @@ -57,7 +57,7 @@ # Now import the module under test -from backend.v4.magentic_agents.proxy_agent import ProxyAgent, create_proxy_agent +import backend.v4.magentic_agents.proxy_agent class TestProxyAgentComplexScenarios: @@ -123,9 +123,8 @@ def test_extract_logic(input_val): def test_timeout_and_error_scenarios(self): """Test timeout and error handling scenarios.""" - import asyncio - - + + # Test that timeout logic would work loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) @@ -880,7 +879,6 @@ async def mock_wait_with_error_handling(request_id): mock_orchestration_config.clarifications = {"test-request": None} # This would test each error path - import asyncio loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) diff --git a/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py b/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py index d25b97e83..333c2f434 100644 --- a/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py +++ b/src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py @@ -8,7 +8,6 @@ import os import sys import unittest -import re # Set up environment variables (removed manual path modification as pytest config handles it) os.environ.update({ diff --git a/src/tests/backend/v4/orchestration/test_human_approval_manager.py b/src/tests/backend/v4/orchestration/test_human_approval_manager.py index 952cbf166..bd1b27fd5 100644 --- a/src/tests/backend/v4/orchestration/test_human_approval_manager.py +++ b/src/tests/backend/v4/orchestration/test_human_approval_manager.py @@ -4,15 +4,11 @@ """ import asyncio -import logging import os import sys import unittest -from typing import Any, Optional from unittest.mock import Mock, AsyncMock, patch -import pytest - # Add the backend directory to the Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend')) diff --git a/src/tests/backend/v4/orchestration/test_orchestration_manager.py b/src/tests/backend/v4/orchestration/test_orchestration_manager.py index 119aa4372..dbc0d1fbc 100644 --- a/src/tests/backend/v4/orchestration/test_orchestration_manager.py +++ b/src/tests/backend/v4/orchestration/test_orchestration_manager.py @@ -7,12 +7,8 @@ import logging import os import sys -import uuid -from typing import List, Optional from unittest import IsolatedAsyncioTestCase -from unittest.mock import AsyncMock, Mock, patch, MagicMock - -import pytest +from unittest.mock import AsyncMock, Mock, patch # Add the backend directory to the Python path sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..', '..', '..', 'backend')) @@ -442,7 +438,7 @@ async def test_get_current_or_new_orchestration_new(self): mock_workflow = Mock() mock_init.return_value = mock_workflow - result = await OrchestrationManager.get_current_or_new_orchestration( + await OrchestrationManager.get_current_or_new_orchestration( user_id=self.test_user_id, team_config=self.test_team_config, team_switched=False, @@ -466,7 +462,7 @@ async def test_get_current_or_new_orchestration_team_switched(self): mock_new_workflow = Mock() mock_init.return_value = mock_new_workflow - result = await OrchestrationManager.get_current_or_new_orchestration( + await OrchestrationManager.get_current_or_new_orchestration( user_id=self.test_user_id, team_config=self.test_team_config, team_switched=True,