From cdf1c50729ea158499fb6b61170c0bffe798c5f2 Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Mon, 9 Feb 2026 17:02:05 +0530 Subject: [PATCH 1/6] refactor: remove unused imports and clean up test files for better readability --- src/tests/backend/auth/test_auth_utils.py | 2 -- src/tests/backend/common/config/test_app_config.py | 4 +--- src/tests/backend/common/database/test_cosmosdb.py | 5 ++--- .../backend/common/database/test_database_base.py | 4 ++-- .../backend/common/database/test_database_factory.py | 3 +-- src/tests/backend/common/utils/test_event_utils.py | 2 +- src/tests/backend/common/utils/test_otlp_tracing.py | 2 +- src/tests/backend/common/utils/test_utils_af.py | 4 +--- src/tests/backend/common/utils/test_utils_agents.py | 5 +---- src/tests/backend/common/utils/test_utils_date.py | 7 ------- src/tests/backend/middleware/test_health_check.py | 4 +--- src/tests/backend/v4/api/test_router.py | 1 - src/tests/backend/v4/callbacks/test_global_debug.py | 3 +-- .../backend/v4/callbacks/test_response_handlers.py | 5 +---- .../v4/common/services/test_base_api_service.py | 2 +- .../v4/common/services/test_foundry_service.py | 8 ++------ .../backend/v4/common/services/test_mcp_service.py | 7 +++---- .../backend/v4/common/services/test_plan_service.py | 4 ++-- .../backend/v4/common/services/test_team_service.py | 7 ++----- src/tests/backend/v4/config/test_settings.py | 4 ++-- .../v4/magentic_agents/common/test_lifecycle.py | 2 +- .../backend/v4/magentic_agents/test_foundry_agent.py | 5 +---- .../v4/magentic_agents/test_magentic_agent_factory.py | 4 +--- .../backend/v4/magentic_agents/test_proxy_agent.py | 10 ++++------ .../helper/test_plan_to_mplan_converter.py | 1 - .../v4/orchestration/test_human_approval_manager.py | 5 +---- .../v4/orchestration/test_orchestration_manager.py | 11 ++++------- 27 files changed, 37 insertions(+), 84 deletions(-) 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..0bfb0e2a7 100644 --- a/src/tests/backend/common/config/test_app_config.py +++ b/src/tests/backend/common/config/test_app_config.py @@ -13,9 +13,7 @@ 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 +from azure.identity import ManagedIdentityCredential # 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..c9096fcb7 100644 --- a/src/tests/backend/common/database/test_cosmosdb.py +++ b/src/tests/backend/common/database/test_cosmosdb.py @@ -4,10 +4,9 @@ import logging import sys import os -from typing import Any, Dict, List, Optional -from unittest.mock import AsyncMock, MagicMock, Mock, patch +from typing import Dict, List, Optional +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..e966968a1 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, patch 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..823b26826 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,7 @@ import sys import importlib.util from unittest.mock import patch, MagicMock, AsyncMock, Mock -from typing import Any, Dict, Optional, Union +from typing import 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..9c5e410de 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,9 @@ 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, Mock +from typing import Dict, Optional +from aiohttp import ClientTimeout, 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..a1985f86f 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, Optional, 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..d0aeb39f7 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,10 @@ 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 typing import Dict, Optional, List, Tuple from datetime import datetime, timezone # Add the src directory to sys.path for proper import diff --git a/src/tests/backend/v4/config/test_settings.py b/src/tests/backend/v4/config/test_settings.py index 1a986482e..6a7cf4280 100644 --- a/src/tests/backend/v4/config/test_settings.py +++ b/src/tests/backend/v4/config/test_settings.py @@ -432,7 +432,7 @@ async def cancel_task(): cancel_task_handle = asyncio.create_task(cancel_task()) with self.assertRaises(asyncio.CancelledError): - await task + result = await task await cancel_task_handle @@ -454,7 +454,7 @@ async def cancel_task(): with self.assertRaises(asyncio.CancelledError): await task - await cancel_task_handle + _ = await cancel_task_handle def test_cleanup_approval(self): """Test cleanup approval.""" 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..ea09cc7c7 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, call 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..1e8771b64 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, patch, 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..48dd63dce 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 +from backend.v4.magentic_agents.proxy_agent import create_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..8b9376cf3 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,12 @@ """ import asyncio -import logging import os import sys import unittest -from typing import Any, Optional +from typing import 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..f4163a903 100644 --- a/src/tests/backend/v4/orchestration/test_orchestration_manager.py +++ b/src/tests/backend/v4/orchestration/test_orchestration_manager.py @@ -7,12 +7,9 @@ import logging import os import sys -import uuid -from typing import List, Optional +from typing import List 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 +439,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 +463,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, From 93ecd36e1de020d2d08ca3ad46da07097c7017d2 Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Mon, 9 Feb 2026 17:06:12 +0530 Subject: [PATCH 2/6] fix: update workflow to include code-quality-fix branch in trigger paths --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 428882567..80eb33b05 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,6 +6,7 @@ on: - main - demo-v4 - dev-v4 + - code-quality-fix paths: - 'src/backend/**/*.py' - 'src/tests/**/*.py' @@ -25,7 +26,7 @@ on: - main - demo-v4 - dev-v4 - paths: + - code-quality-fix - 'src/backend/**/*.py' - 'src/tests/**/*.py' - 'src/mcp_server/**/*.py' From 2b601b373d1d6b8f79902f18116bb60ca900cf5f Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Mon, 9 Feb 2026 17:08:58 +0530 Subject: [PATCH 3/6] fix: remove code-quality-fix branch from workflow trigger paths --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 80eb33b05..6ff949317 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,6 @@ on: - main - demo-v4 - dev-v4 - - code-quality-fix paths: - 'src/backend/**/*.py' - 'src/tests/**/*.py' @@ -26,7 +25,6 @@ on: - main - demo-v4 - dev-v4 - - code-quality-fix - 'src/backend/**/*.py' - 'src/tests/**/*.py' - 'src/mcp_server/**/*.py' From 2a5d61c0c33e7c7fc663248add91722915b4eeb6 Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Tue, 10 Feb 2026 13:48:28 +0530 Subject: [PATCH 4/6] refactor: remove unused imports from test files for improved code quality --- src/tests/backend/common/config/test_app_config.py | 1 - src/tests/backend/common/database/test_cosmosdb.py | 1 - src/tests/backend/common/database/test_database_base.py | 2 +- src/tests/backend/v4/common/services/test_base_api_service.py | 1 - src/tests/backend/v4/common/services/test_mcp_service.py | 3 +-- src/tests/backend/v4/common/services/test_team_service.py | 1 - src/tests/backend/v4/config/test_settings.py | 4 ++-- src/tests/backend/v4/magentic_agents/test_foundry_agent.py | 2 +- .../backend/v4/magentic_agents/test_magentic_agent_factory.py | 2 +- .../backend/v4/orchestration/test_human_approval_manager.py | 1 - 10 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/tests/backend/common/config/test_app_config.py b/src/tests/backend/common/config/test_app_config.py index 0bfb0e2a7..2652d4532 100644 --- a/src/tests/backend/common/config/test_app_config.py +++ b/src/tests/backend/common/config/test_app_config.py @@ -13,7 +13,6 @@ import os import logging from unittest.mock import patch, MagicMock, AsyncMock -from azure.identity import ManagedIdentityCredential # 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 c9096fcb7..31cfe34ce 100644 --- a/src/tests/backend/common/database/test_cosmosdb.py +++ b/src/tests/backend/common/database/test_cosmosdb.py @@ -4,7 +4,6 @@ import logging import sys import os -from typing import Dict, List, Optional from unittest.mock import AsyncMock, Mock, patch import pytest diff --git a/src/tests/backend/common/database/test_database_base.py b/src/tests/backend/common/database/test_database_base.py index e966968a1..0eba3ba6f 100644 --- a/src/tests/backend/common/database/test_database_base.py +++ b/src/tests/backend/common/database/test_database_base.py @@ -4,7 +4,7 @@ import os from abc import ABC from typing import Any, Dict, List, Optional, Type -from unittest.mock import Mock, patch +from unittest.mock import Mock 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 823b26826..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 Dict, Optional, Union import aiohttp from aiohttp import ClientTimeout, ClientSession 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 9c5e410de..4b1f43270 100644 --- a/src/tests/backend/v4/common/services/test_mcp_service.py +++ b/src/tests/backend/v4/common/services/test_mcp_service.py @@ -14,8 +14,7 @@ import sys import asyncio import importlib.util -from unittest.mock import patch, MagicMock, Mock -from typing import Dict, Optional +from unittest.mock import patch, MagicMock from aiohttp import ClientTimeout, ClientError # 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 d0aeb39f7..0fe9d9495 100644 --- a/src/tests/backend/v4/common/services/test_team_service.py +++ b/src/tests/backend/v4/common/services/test_team_service.py @@ -19,7 +19,6 @@ import uuid import importlib.util from unittest.mock import patch, MagicMock, AsyncMock -from typing import Dict, Optional, List, Tuple from datetime import datetime, timezone # Add the src directory to sys.path for proper import diff --git a/src/tests/backend/v4/config/test_settings.py b/src/tests/backend/v4/config/test_settings.py index 6a7cf4280..1a986482e 100644 --- a/src/tests/backend/v4/config/test_settings.py +++ b/src/tests/backend/v4/config/test_settings.py @@ -432,7 +432,7 @@ async def cancel_task(): cancel_task_handle = asyncio.create_task(cancel_task()) with self.assertRaises(asyncio.CancelledError): - result = await task + await task await cancel_task_handle @@ -454,7 +454,7 @@ async def cancel_task(): with self.assertRaises(asyncio.CancelledError): await task - _ = await cancel_task_handle + await cancel_task_handle def test_cleanup_approval(self): """Test cleanup approval.""" 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 ea09cc7c7..97da0b31e 100644 --- a/src/tests/backend/v4/magentic_agents/test_foundry_agent.py +++ b/src/tests/backend/v4/magentic_agents/test_foundry_agent.py @@ -2,7 +2,7 @@ import sys import os -from unittest.mock import Mock, patch, AsyncMock, 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 1e8771b64..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 @@ -2,7 +2,7 @@ import logging import sys from types import SimpleNamespace -from unittest.mock import Mock, patch, AsyncMock +from unittest.mock import Mock, AsyncMock import pytest # Mock the dependencies before importing the module under test 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 8b9376cf3..bd1b27fd5 100644 --- a/src/tests/backend/v4/orchestration/test_human_approval_manager.py +++ b/src/tests/backend/v4/orchestration/test_human_approval_manager.py @@ -7,7 +7,6 @@ import os import sys import unittest -from typing import Optional from unittest.mock import Mock, AsyncMock, patch # Add the backend directory to the Python path From d69b7fc360ef628bce63fbd1d0f251b9b61593eb Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Tue, 10 Feb 2026 13:56:07 +0530 Subject: [PATCH 5/6] refactor: remove unused imports from test files for improved code quality --- src/tests/backend/v4/common/services/test_mcp_service.py | 2 +- src/tests/backend/v4/common/services/test_plan_service.py | 2 +- src/tests/backend/v4/magentic_agents/test_proxy_agent.py | 2 +- .../backend/v4/orchestration/test_orchestration_manager.py | 1 - 4 files changed, 3 insertions(+), 4 deletions(-) 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 4b1f43270..04e0844d8 100644 --- a/src/tests/backend/v4/common/services/test_mcp_service.py +++ b/src/tests/backend/v4/common/services/test_mcp_service.py @@ -15,7 +15,7 @@ import asyncio import importlib.util from unittest.mock import patch, MagicMock -from aiohttp import ClientTimeout, ClientError +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 a1985f86f..455200af7 100644 --- a/src/tests/backend/v4/common/services/test_plan_service.py +++ b/src/tests/backend/v4/common/services/test_plan_service.py @@ -18,7 +18,7 @@ import logging import importlib.util from unittest.mock import patch, MagicMock, AsyncMock -from typing import Any, Optional, List +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/magentic_agents/test_proxy_agent.py b/src/tests/backend/v4/magentic_agents/test_proxy_agent.py index 48dd63dce..ca734df44 100644 --- a/src/tests/backend/v4/magentic_agents/test_proxy_agent.py +++ b/src/tests/backend/v4/magentic_agents/test_proxy_agent.py @@ -57,7 +57,7 @@ # Now import the module under test -from backend.v4.magentic_agents.proxy_agent import create_proxy_agent +import backend.v4.magentic_agents.proxy_agent class TestProxyAgentComplexScenarios: diff --git a/src/tests/backend/v4/orchestration/test_orchestration_manager.py b/src/tests/backend/v4/orchestration/test_orchestration_manager.py index f4163a903..dbc0d1fbc 100644 --- a/src/tests/backend/v4/orchestration/test_orchestration_manager.py +++ b/src/tests/backend/v4/orchestration/test_orchestration_manager.py @@ -7,7 +7,6 @@ import logging import os import sys -from typing import List from unittest import IsolatedAsyncioTestCase from unittest.mock import AsyncMock, Mock, patch From 3b8654f85f55f5f77b48b21970fea202b7cc5380 Mon Sep 17 00:00:00 2001 From: Kingshuk-Microsoft Date: Fri, 13 Feb 2026 17:44:44 +0530 Subject: [PATCH 6/6] fix: add missing paths section for pull request trigger in workflow --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6ff949317..428882567 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,7 @@ on: - main - demo-v4 - dev-v4 + paths: - 'src/backend/**/*.py' - 'src/tests/**/*.py' - 'src/mcp_server/**/*.py'