-
Notifications
You must be signed in to change notification settings - Fork 12
[Feature] Add pytest-cov for code coverage reporting #244
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 <noreply@anthropic.com>
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 <noreply@anthropic.com>
There was a problem hiding this 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
Nonechannel_data gracefully - Made
channel_dataoptional inConversationUpdateActivityby 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__.:", |
Copilot
AI
Jan 15, 2026
There was a problem hiding this comment.
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__'.
| "if __name__ == .__main__.:", | |
| "if __name__ == \"__main__\":", |
Related to #64
Summary
Adds pytest-cov tooling and configuration to enable code coverage tracking and reporting for the repository.
Changes
[tool.coverage]sections with source paths, omit patterns, and exclusionsuv run poe test-cov- Run tests with terminal + HTML coverage reportuv run poe test-cov-xml- Generate XML coverage report (useful for CI)Configuration Details
Source:
packages/directoryOmit patterns:
*/tests/*- Test files themselves*/__pycache__/*- Python cache*/venv/*,*/.venv/*- Virtual environmentsExclusion patterns (lines excluded from coverage):
pragma: no cover- Explicit coverage skipif __name__ == .__main__.:blocksCurrent Coverage Baseline
Ran full test suite with coverage to establish baseline:
By Package:
Usage
Next Steps
As identified in #64, follow-up work includes:
This PR establishes the foundation for tracking and improving test coverage across the repository.
🤖 Generated with Claude Code