Skip to content

Conversation

@rajan-chari
Copy link
Contributor

Related to #64

Summary

Adds pytest-cov tooling and configuration to enable code coverage tracking and reporting for the repository.

Changes

  1. Added pytest-cov to dev dependencies - Version >=6.0.0 added to root pyproject.toml
  2. Configured coverage settings - Added [tool.coverage] sections with source paths, omit patterns, and exclusions
  3. Added poe tasks - New commands for running tests with coverage:
    • uv run poe test-cov - Run tests with terminal + HTML coverage report
    • uv run poe test-cov-xml - Generate XML coverage report (useful for CI)
  4. Updated .gitignore - Exclude coverage artifacts (.coverage, htmlcov/, coverage.xml)

Configuration Details

Source: packages/ directory
Omit patterns:

  • */tests/* - Test files themselves
  • */__pycache__/* - Python cache
  • */venv/*, */.venv/* - Virtual environments

Exclusion patterns (lines excluded from coverage):

  • pragma: no cover - Explicit coverage skip
  • Abstract methods and TYPE_CHECKING blocks
  • if __name__ == .__main__.: blocks
  • Repr and error raising methods

Current Coverage Baseline

Ran full test suite with coverage to establish baseline:

TOTAL: 12,446 statements, 2,999 missed
Overall Coverage: 75.90%

By Package:

  • api + apps: 85.04% (236 tests, well covered)
  • openai: 90%+ (excellent coverage)
  • ⚠️ cards: 62.63% (many untested builder methods in generated code)
  • ⚠️ common: ~85% (good coverage)
  • mcpplugin: 31% (server_plugin and transport need tests)

Usage

# Run tests with coverage report
uv run poe test-cov

# Generate XML coverage for CI
uv run poe test-cov-xml

# Open HTML coverage report
open htmlcov/index.html

Next Steps

As identified in #64, follow-up work includes:

  1. Add tests for untested packages (a2aprotocol, devtools)
  2. Improve coverage for minimally-tested packages (ai, botbuilder, graph, mcpplugin)
  3. Set up CI coverage checks with minimum thresholds
  4. Add coverage badge to README

This PR establishes the foundation for tracking and improving test coverage across the repository.

🤖 Generated with Claude Code

rajan-chari and others added 2 commits January 15, 2026 12:49
Make channel_data optional in ConversationUpdateActivity to support Direct Line API 3.0, which sends conversationUpdate activities without channelData field. This fixes validation errors when receiving messages from Direct Line.

Changes:
- Remove required channel_data field override in ConversationUpdateActivity
- Add null checks in activity route selectors before accessing channel_data.event_type
- Add comprehensive tests for Direct Line compatibility (8 new tests)
- All tests pass (236 total, up from 228)

Test Coverage:
- ConversationUpdateActivity parsing without channelData (Direct Line scenario)
- ConversationUpdateActivity parsing with channelData (Teams scenario)
- Activity routing with and without channelData
- All event-specific selectors handle None channelData gracefully

Fixes #239

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Add pytest-cov tooling and configuration to enable code coverage tracking and reporting.

Changes:
- Add pytest-cov>=6.0.0 to dev dependencies
- Configure coverage settings in pyproject.toml (source, omit patterns, exclusions)
- Add poe tasks for running tests with coverage (test-cov, test-cov-xml)
- Update .gitignore to exclude coverage artifacts (.coverage, htmlcov/, coverage.xml)

Coverage Configuration:
- Source: packages/
- Omit: tests, __pycache__, venv directories
- Exclude lines: pragma no cover, abstract methods, TYPE_CHECKING blocks
- HTML reports generated in htmlcov/ directory

Usage:
  uv run poe test-cov          # Run tests with coverage report
  uv run poe test-cov-xml      # Generate XML coverage report for CI

Current Coverage Status:
- Overall: 75.90% (236 tests passing)
- api + apps: 85.04% (well covered)
- cards: 62.63% (many untested builder methods)
- openai: 90%+ (excellent coverage)
- mcpplugin: 31% (needs improvement)

Related to #64

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 15, 2026 18:45
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 adds pytest-cov for code coverage tracking and reporting, while also fixing a bug where conversation update activity routing selectors failed when channel_data was None (as with Direct Line).

Changes:

  • Added pytest-cov configuration and tooling for coverage reporting
  • Fixed bug in activity routing selectors to handle None channel_data gracefully
  • Made channel_data optional in ConversationUpdateActivity by removing the required override
  • Added comprehensive tests for conversation update routing with and without channel_data

Reviewed changes

Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Added pytest-cov to dev dependencies, configured coverage settings, and added poe tasks for running tests with coverage
packages/apps/tests/test_conversation_update_routing.py New test file verifying routing selectors handle None channel_data without errors
packages/apps/src/microsoft_teams/apps/routing/activity_route_configs.py Added null checks for channel_data in event-specific routing selectors
packages/api/tests/unit/test_conversation_update_directline.py New test file verifying Direct Line compatibility with missing channel_data
packages/api/src/microsoft_teams/api/activities/conversation/conversation_update.py Removed required channel_data override, making it optional in ConversationUpdateActivity
.gitignore Added coverage artifacts to gitignore (.coverage, htmlcov/, coverage.xml, tmpclaude-*-cwd)

"def __repr__",
"raise AssertionError",
"raise NotImplementedError",
"if __name__ == .__main__.:",
Copy link

Copilot AI Jan 15, 2026

Choose a reason for hiding this comment

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

The regex pattern for excluding if __name__ == \"__main__\": blocks is incorrect. The pattern uses literal dots instead of escaped quotes, which won't match the actual Python idiom. Change .__main__. to \"__main__\" or '__main__'.

Suggested change
"if __name__ == .__main__.:",
"if __name__ == \"__main__\":",

Copilot uses AI. Check for mistakes.
@rajan-chari rajan-chari marked this pull request as draft January 15, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants