🔭 Task Overview
The GitHubClient class in src/ciftt/github/client.py currently has only 18% test coverage, which is significantly below the project's 80% requirement. This low coverage allowed a bug (incorrect imports in update_issue_project_fields) to slip through testing and only be caught in production.
🎯 Objectives
- Increase test coverage for
src/ciftt/github/client.py from 18% to at least 80%
- Add unit tests that actually test the real
GitHubClient methods, not just mocked versions
- Ensure critical methods like
update_issue_project_fields have comprehensive test coverage
- Catch import errors and other issues that are currently hidden by mocking
🔬 Steps or Implementation Details
- Analyze current coverage gaps: Run
pytest --cov=src/ciftt/github/client.py --cov-report=term-missing to identify untested lines
- Create unit test file: Add
tests/test_github_client.py for direct GitHubClient testing
- Mock at the right level: Instead of mocking the entire
GitHubClient object, mock the underlying requests library or use VCR.py to record/replay HTTP interactions
- Test critical methods:
update_issue_project_fields() (lines 257-313)
_update_project_fields() (lines 315-368)
_find_target_project() (lines 387-447)
- GraphQL query methods
- Rate limit handling integration
- Test error paths: Ensure error handling and edge cases are covered
- Verify imports execute: Tests should actually run the code (not mock it) so lazy imports inside methods are tested
📝 Additional context
Root cause of missed bug:
- The buggy imports (
from github.client_utils import ... on lines 278 and 337) were inside methods
- Integration tests mocked the entire
GitHubClient, so these imports never executed
- The import error only surfaced when running the actual CLI tool
Current test approach:
# Current integration tests (conftest.py)
mock_github_client = Mock() # Entire client is mocked
mock_github_client.update_issue_project_fields.return_value = ...
Proposed unit test approach:
# Proposed unit tests
@patch('requests.post') # Mock at HTTP level, not client level
def test_update_issue_project_fields(mock_post):
client = GitHubClient(token="test-token") # Real client instance
result = client.update_issue_project_fields(...) # Actually runs the code
Coverage report showing the problem:
src/ciftt/github/client.py 190 155 18% (missing lines: 38-43, 47-53, 59-79, 83-92, ...)
Related issue: The bug fixed in commit fixing incorrect imports in update_issue_project_fields
🔭 Task Overview
The
GitHubClientclass insrc/ciftt/github/client.pycurrently has only 18% test coverage, which is significantly below the project's 80% requirement. This low coverage allowed a bug (incorrect imports inupdate_issue_project_fields) to slip through testing and only be caught in production.🎯 Objectives
src/ciftt/github/client.pyfrom 18% to at least 80%GitHubClientmethods, not just mocked versionsupdate_issue_project_fieldshave comprehensive test coverage🔬 Steps or Implementation Details
pytest --cov=src/ciftt/github/client.py --cov-report=term-missingto identify untested linestests/test_github_client.pyfor directGitHubClienttestingGitHubClientobject, mock the underlyingrequestslibrary or use VCR.py to record/replay HTTP interactionsupdate_issue_project_fields()(lines 257-313)_update_project_fields()(lines 315-368)_find_target_project()(lines 387-447)📝 Additional context
Root cause of missed bug:
from github.client_utils import ...on lines 278 and 337) were inside methodsGitHubClient, so these imports never executedCurrent test approach:
Proposed unit test approach:
Coverage report showing the problem:
Related issue: The bug fixed in commit fixing incorrect imports in
update_issue_project_fields