[Feature] Add pytest-cov for code coverage reporting#244
Draft
rajan-chari wants to merge 2 commits intomainfrom
Draft
[Feature] Add pytest-cov for code coverage reporting#244rajan-chari wants to merge 2 commits intomainfrom
rajan-chari wants to merge 2 commits intomainfrom
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>
Contributor
There was a problem hiding this comment.
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__.:", |
There was a problem hiding this comment.
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__\":", |
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.
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