Skip to content

Python: Achieve 85%+ unit test coverage for azurefunctions package#3866

Merged
TaoChenOSU merged 10 commits intomainfrom
copilot/track-azurefunctions-coverage
Feb 13, 2026
Merged

Python: Achieve 85%+ unit test coverage for azurefunctions package#3866
TaoChenOSU merged 10 commits intomainfrom
copilot/track-azurefunctions-coverage

Conversation

Copy link
Contributor

Copilot AI commented Feb 11, 2026

Motivation and Context

The azurefunctions GA package required 85% unit test coverage. Initial state: 80% coverage with significant gaps in error handling, edge cases, and utility methods.

Description

Increased coverage from 80% to 86% through surgical test additions targeting uncovered code paths.

Coverage by module:

  • _errors.py: 50% → 100% (4 tests added)
  • _entities.py: 86% → 100% (5 tests added)
  • _orchestration.py: 93% → 100% (2 tests added)
  • _app.py: 77% → 81% (10 tests added)

Test additions:

  • test_errors.py: New file for exception initialization and custom status codes
  • test_entities.py: Input validation, event loop handling, async edge cases
  • test_orchestration.py: Exception handling during response conversion, UUID generation
  • test_app.py: Parameter validation, utility methods, boolean coercion, JSON parsing

Code quality improvements:

  • Fixed SIM117 linting violations by combining nested with statements in test files
  • Removed unused variables and unreachable code based on PR review feedback
  • Removed brittle line number references from test docstrings for better maintainability
  • Improved test clarity and documentation to accurately describe tested behavior

All tests follow existing patterns. No breaking changes. Test suite: 80 → 101 tests.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.
Original prompt

This section details on the original issue you should resolve

<issue_title>Python: azurefunctions package unit test coverage tracking</issue_title>
<issue_description>### Description

Track and ensure the azurefunctions GA package achieves 85% unit test coverage as part of the overall requirement. Report current status, gaps, and actions needed to meet the threshold.

Package Versions

agent-framework-azurefunctions</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits February 11, 2026 20:45
Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
…ns package

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
…ckage

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
Copilot AI changed the title [WIP] Track unit test coverage for azurefunctions package Python: Achieve 85%+ unit test coverage for azurefunctions package Feb 11, 2026
Copilot AI requested a review from larohra February 11, 2026 20:58
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation python labels Feb 11, 2026
@larohra
Copy link
Contributor

larohra commented Feb 11, 2026

@copilot can you fix the failing checks

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot can you fix the failing checks

Fixed the linting errors in commit fc4844f. The issue was nested with statements in test_entities.py that needed to be combined per the SIM117 ruff rule. All checks now pass:

  • ✅ ruff lint
  • ✅ ruff format
  • ✅ pyright
  • ✅ mypy
  • ✅ All 101 tests passing
  • ✅ Coverage maintained at 86%

Copy link
Contributor

@larohra larohra left a comment

Choose a reason for hiding this comment

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

@copilot fix these

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 11, 2026

@copilot fix these

Fixed both review comments in commit 5e8244b:

  • ✅ Removed COVERAGE_REPORT.md
  • ✅ Removed coverage.json
  • ✅ All tests still pass (101 passed, 21 skipped)
  • ✅ Coverage maintained at 86%

Copilot AI requested a review from larohra February 11, 2026 22:06
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 11, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL20476321584% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
3944 225 💤 0 ❌ 0 🔥 1m 12s ⏱️

@larohra larohra marked this pull request as ready for review February 11, 2026 22:14
@larohra larohra requested a review from a team as a code owner February 11, 2026 22:14
Copilot AI review requested due to automatic review settings February 11, 2026 22:14
Copy link
Contributor

Copilot AI left a comment

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 increases unit test coverage for the agent-framework-azurefunctions Python package to meet/exceed the 85% GA requirement by adding targeted tests for previously uncovered paths in orchestration, entities, request parsing, and custom errors.

Changes:

  • Added new unit tests for orchestration helpers (AgentTask.try_set_value) and executor ID generation.
  • Added a new test module for _errors.py (IncomingRequestError) and expanded tests around entity execution edge cases.
  • Expanded AgentFunctionApp tests to cover request parsing/coercion helpers and various error/validation paths.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 6 comments.

File Description
python/packages/azurefunctions/tests/test_orchestration.py Adds coverage for AgentTask exception handling and AzureFunctionsAgentExecutor.generate_unique_id.
python/packages/azurefunctions/tests/test_errors.py New tests covering IncomingRequestError behavior and status code handling.
python/packages/azurefunctions/tests/test_entities.py Adds tests for non-dict inputs and event loop edge cases in durable entity execution.
python/packages/azurefunctions/tests/test_app.py Adds tests for AgentFunctionApp helper methods (parsing, coercion, session/thread id handling) and init validation.

… from docstrings, improve test clarity

Co-authored-by: larohra <41490930+larohra@users.noreply.github.com>
Copilot AI requested a review from larohra February 12, 2026 06:21
@TaoChenOSU TaoChenOSU enabled auto-merge February 13, 2026 19:26
@TaoChenOSU TaoChenOSU added this pull request to the merge queue Feb 13, 2026
Merged via the queue into main with commit cd1e311 Feb 13, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: azurefunctions package unit test coverage tracking

5 participants