Skip to content

refactor: Code quality fix#808

Merged
Roopan-Microsoft merged 6 commits into
dev-v4from
code-quality-fix
Feb 26, 2026
Merged

refactor: Code quality fix#808
Roopan-Microsoft merged 6 commits into
dev-v4from
code-quality-fix

Conversation

@Kingshuk-Microsoft

Copy link
Copy Markdown
Contributor

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:

  • Added logic to the postdeploy scripts in both azure.yaml and azure_custom.yaml to 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:

  • Removed unused imports such as logging, uuid, and pytest from various test files to reduce clutter and potential confusion. [1] [2] [3] [4] [5] [6] [7] [8]
  • Standardized unittest.mock imports to only include necessary mock classes, removing unused ones like MagicMock and AsyncMock where not needed. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Specific test logic:

  • Cleaned up test modules by removing unnecessary or duplicate imports, such as removing importlib.util, aiohttp, and redundant type hints. [1] [2] [3] [4] [5]
  • Removed unused or obsolete test dependencies, such as pytest and 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?

  • Yes
  • No

How to Test

  • Get the code
git clone [repo-address]
cd [repo-name]
git checkout [branch-name]
npm install
  • Test the code

What to Check

Verify that the following are valid
GP testing

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 unnecessary Mock variants).
  • Minor test logic tweaks to remove unused return-value assignments / variables.
  • Updated .github/workflows/test.yml trigger configuration (but currently introduces an invalid/ineffective pull_request trigger).

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_request trigger, the file globs appear to be listed under branches (e.g., src/backend/**/*.py), which makes the workflow trigger configuration invalid/ineffective. These entries should be moved under a paths: key (similar to the push trigger), leaving branches: 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.

Comment thread src/tests/backend/v4/config/test_settings.py Outdated
Comment thread src/tests/backend/v4/config/test_settings.py Outdated
Comment thread src/tests/backend/common/config/test_app_config.py Outdated
Comment thread src/tests/backend/v4/common/services/test_base_api_service.py Outdated
Comment thread src/tests/backend/common/database/test_cosmosdb.py Outdated
Comment thread src/tests/backend/v4/common/services/test_mcp_service.py Outdated
Comment thread src/tests/backend/v4/orchestration/test_orchestration_manager.py Outdated
Comment thread src/tests/backend/v4/common/services/test_plan_service.py Outdated
Comment thread src/tests/backend/v4/magentic_agents/test_proxy_agent.py Outdated
Comment thread src/tests/backend/v4/common/services/test_team_service.py Outdated
@Roopan-Microsoft Roopan-Microsoft merged commit 9aa0490 into dev-v4 Feb 26, 2026
3 checks passed
@github-actions

github-actions Bot commented Mar 2, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 4.0.7 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@Roopan-Microsoft Roopan-Microsoft deleted the code-quality-fix branch March 4, 2026 12:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants