refactor: Code quality fix#808
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR focuses on refactoring backend test code by removing unused imports and simplifying unittest.mock import lists, and it also updates the CI test workflow trigger configuration.
Changes:
- Cleaned up unused imports across many Python test modules (e.g., removing unused
pytest,logging,uuid, and unnecessaryMockvariants). - Minor test logic tweaks to remove unused return-value assignments / variables.
- Updated
.github/workflows/test.ymltrigger configuration (but currently introduces an invalid/ineffectivepull_requesttrigger).
Reviewed changes
Copilot reviewed 28 out of 28 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/backend/v4/orchestration/test_orchestration_manager.py | Removes unused imports and drops unused local result assignments in a couple tests. |
| src/tests/backend/v4/orchestration/test_human_approval_manager.py | Removes unused imports (e.g., logging, pytest, unused typing). |
| src/tests/backend/v4/orchestration/helper/test_plan_to_mplan_converter.py | Removes unused re import. |
| src/tests/backend/v4/magentic_agents/test_proxy_agent.py | Removes unused MagicMock import and unused module import (ProxyAgent). |
| src/tests/backend/v4/magentic_agents/test_magentic_agent_factory.py | Removes unused imports and trims mock imports. |
| src/tests/backend/v4/magentic_agents/test_foundry_agent.py | Removes unused imports and trims mock imports. |
| src/tests/backend/v4/magentic_agents/common/test_lifecycle.py | Trims mock imports. |
| src/tests/backend/v4/config/test_settings.py | Small async test adjustments (currently adds some unused assignments). |
| src/tests/backend/v4/common/services/test_team_service.py | Removes unused imports and simplifies typing/mock imports. |
| src/tests/backend/v4/common/services/test_plan_service.py | Simplifies typing/mock imports. |
| src/tests/backend/v4/common/services/test_mcp_service.py | Removes unused imports and simplifies aiohttp imports. |
| src/tests/backend/v4/common/services/test_foundry_service.py | Removes unused imports and simplifies typing/mock imports. |
| src/tests/backend/v4/common/services/test_base_api_service.py | Simplifies typing imports. |
| src/tests/backend/v4/callbacks/test_response_handlers.py | Removes unused imports and trims mock imports. |
| src/tests/backend/v4/callbacks/test_global_debug.py | Removes unused imports (patch, pytest). |
| src/tests/backend/v4/api/test_router.py | Removes unused asyncio import. |
| src/tests/backend/middleware/test_health_check.py | Removes unused imports and trims mock imports. |
| src/tests/backend/common/utils/test_utils_date.py | Removes unused imports (including unused pytest and redundant parser import). |
| src/tests/backend/common/utils/test_utils_agents.py | Removes unused imports and drops unused model symbols. |
| src/tests/backend/common/utils/test_utils_af.py | Removes unused imports and trims mock imports. |
| src/tests/backend/common/utils/test_otlp_tracing.py | Trims mock imports. |
| src/tests/backend/common/utils/test_event_utils.py | Trims mock imports. |
| src/tests/backend/common/database/test_database_factory.py | Removes unused imports and trims mock imports. |
| src/tests/backend/common/database/test_database_base.py | Removes unused imports (abstractmethod, AsyncMock). |
| src/tests/backend/common/database/test_cosmosdb.py | Removes unused imports and trims typing/mock imports. |
| src/tests/backend/common/config/test_app_config.py | Removes unused Azure SDK imports from the test module. |
| src/tests/backend/auth/test_auth_utils.py | Removes unused imports (logging, importlib.util). |
| .github/workflows/test.yml | Modifies workflow triggers; currently misconfigures pull_request paths vs branches. |
Comments suppressed due to low confidence (1)
.github/workflows/test.yml:35
- In the
pull_requesttrigger, the file globs appear to be listed underbranches(e.g.,src/backend/**/*.py), which makes the workflow trigger configuration invalid/ineffective. These entries should be moved under apaths:key (similar to thepushtrigger), leavingbranches:to contain only branch names.
pull_request:
types:
- opened
- ready_for_review
- reopened
- synchronize
branches:
- main
- demo-v4
- dev-v4
- 'src/backend/**/*.py'
- 'src/tests/**/*.py'
- 'src/mcp_server/**/*.py'
- 'pytest.ini'
- 'conftest.py'
- 'src/backend/requirements.txt'
- 'src/**/pyproject.toml'
- '.github/workflows/test.yml'
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Roopan-Microsoft
approved these changes
Feb 13, 2026
|
🎉 This PR is included in version 4.0.7 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request primarily cleans up and standardizes the imports in the backend test files, removing unused modules and streamlining mock imports. Additionally, it enhances the post-deployment scripts in Azure configuration files to better support both Bash and PowerShell environments.
Azure Deployment Script Improvements:
postdeployscripts in bothazure.yamlandazure_custom.yamlto detect if the environment is Bash (e.g., Git Bash/MSYS2) or PowerShell, and display tailored instructions for each, improving developer experience when running post-deployment steps. [1] [2] [3] [4]Test Import Cleanup and Standardization:
General test files:
logging,uuid, andpytestfrom various test files to reduce clutter and potential confusion. [1] [2] [3] [4] [5] [6] [7] [8]unittest.mockimports to only include necessary mock classes, removing unused ones likeMagicMockandAsyncMockwhere not needed. [1] [2] [3] [4] [5] [6] [7] [8] [9]Specific test logic:
importlib.util,aiohttp, and redundant type hints. [1] [2] [3] [4] [5]pytestand certain mocked modules, for a leaner test setup. [1] [2]These changes collectively improve code maintainability, reduce unnecessary dependencies, and enhance the clarity and usability of deployment scripts and test files.
Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
GP testing