Open
Description
🧪 Add Unit Tests and Test Coverage
Problem
The DevRev MCP server currently lacks automated testing, which makes it harder to maintain code quality, catch regressions, and ensure reliability across different environments.
Proposed Solution
Implement a comprehensive test suite using pytest with mocked DevRev API responses to ensure reliable testing without requiring live API access.
Acceptance Criteria
📋 Core Testing Infrastructure
- Set up pytest framework with proper project structure
- Configure test discovery and execution
- Add test dependencies to
pyproject.toml
- Create
tests/
directory with proper organization
🔧 API Mocking
- Mock DevRev API responses using
responses
orhttpx-mock
library - Create fixtures for common API response scenarios (success, error, timeout)
- Mock authentication and API key validation
✅ Test Coverage
- Unit tests for
server.py
- all tool handlers (search
,get_object
,create_object
,update_object
) - Unit tests for
utils.py
-make_devrev_request
function with various scenarios - Integration tests for complete tool workflows
- Error handling tests (invalid inputs, API failures, network issues)
- Edge case testing (empty responses, malformed data)
📊 Coverage Reporting
- Set up coverage.py for test coverage measurement
- Achieve minimum 80% test coverage
- Generate HTML coverage reports
- Add coverage badge to README
🚀 CI/CD Integration
- Create GitHub Actions workflow for automated testing
- Run tests on multiple Python versions (3.11, 3.12+)
- Run tests on push and pull request events
- Fail CI if coverage drops below threshold
Technical Implementation Notes
- Use pytest fixtures for reusable test data
- Separate unit tests from integration tests
- Mock external dependencies (DevRev API, environment variables)
- Test both successful and failure scenarios
- Ensure tests are deterministic and can run in any order
Resources
Labels
good first issue
, testing
, infrastructure
This issue is perfect for contributors who want to improve code quality and learn about testing best practices in Python projects.