Skip to content

Improve test coverage across pure-Python models and Config#15

Open
blindndangerous wants to merge 16 commits intomasonasons:masterfrom
blindndangerous:feature/improve-test-coverage
Open

Improve test coverage across pure-Python models and Config#15
blindndangerous wants to merge 16 commits intomasonasons:masterfrom
blindndangerous:feature/improve-test-coverage

Conversation

@blindndangerous
Copy link
Copy Markdown
Contributor

@blindndangerous blindndangerous commented Mar 23, 2026

Summary

Adds 354 new tests across 5 new test files, bringing key modules from 0% to near-complete coverage without requiring a running wx app.

File Before After
models/content.py 0% 100%
models/workflow.py 32% 100%
models/event.py 28% 99%
models/notification.py 0% 95%
config.py 0% 69%

The 69% on config.py and 95% on notification.py represent file I/O paths and except Exception handlers that can't be triggered without deliberately corrupting objects — those are correct to leave uncovered.

New test files

  • tests/test_config.py — Config MutableMapping contract, get/set/del, attribute routing, dict-wrapping behaviour (the bug that caused a real production issue), close() idempotency, child→parent save delegation
  • tests/test_models_content.py — ContentItem parsing, get_display_name, get_size_str for all size buckets
  • tests/test_models_notification.py — Notification/NotificationSubject parsing, all 12 reason display strings, type icons, format_display, get_web_url, relative time buckets
  • tests/test_event_descriptions.py — Every branch of get_action_description (all event types, all action sub-types, with and without titles), format_display, get_web_url for every event type, get_actor_url, relative time buckets
  • tests/test_models_workflow.py — Workflow, WorkflowRun, WorkflowJob parsing, all status/conclusion icon combinations, duration formatting, relative time
  • tests/test_config_io.py — Config file I/O, save/load roundtrips, portable mode detection, platform path dispatch
  • tests/test_repo_sync_mocked.py — RepoSyncManager with subprocess mocked: defaults, get/set config, sync_one error/success paths, push logic, LFS sync
  • tests/test_github_api_mocked.py — GitHubAccount API methods with requests.Session mocked: repos, issues, comments, CRUD, GraphQL
  • tests/test_smoke.py — All major modules import cleanly, constants correct, core classes instantiate without crashing

Test plan

  • pytest tests/ → 706 passed, 0 failed

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.6 <claude[bot]@users.noreply.github.com>

blindndangerous and others added 16 commits March 22, 2026 20:07
Covers MutableMapping contract, get/set/del, attribute access, the
dict-wrapping side-effect (stored dicts become Config objects, not plain
dicts), close() idempotency, and child-to-parent save delegation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers from_github_api field mapping, missing-field defaults,
get_display_name for files and directories, and get_size_str for all
size buckets (bytes, KB, MB).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers from_api field mapping, datetime parsing (valid/invalid/absent),
all known reason display strings, type icons, format_display read/unread
states, get_web_url API-to-web URL conversion, and all relative time
buckets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers get_action_description for all event types (WatchEvent, ForkEvent,
CreateEvent, DeleteEvent, PushEvent, Discussion*, Issues*, IssueComment*,
PullRequest*, PullRequestReview*, Release, CommitComment, Gollum, Member,
Public, and unknown fallback), format_display, get_web_url for every
event-type branch, get_actor_url, and _format_relative_time buckets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers from_github_api field mapping for all three models, format_display
active/inactive states, get_status_icon for all status/conclusion
combinations, get_status_text, WorkflowJob duration formatting, and
_format_relative_time buckets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds full coverage for WorkflowJob.from_github_api, get_status_icon,
get_duration (seconds/minutes/hours/no-end), and format_display.
Also covers the invalid-datetime exception paths in Workflow and
WorkflowRun that were previously uncovered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds parametrized tests for every IssuesEvent and PullRequestEvent action
variant when the issue/PR title is absent, ensuring the title-less string
format is correct. Adds PullRequestReviewEvent no-title variants and the
DiscussionCommentEvent reply_to_id field (alternate reply detection field
used by some API payloads).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds the four specific missing paths: IssuesEvent labeled-with-title,
IssueCommentEvent deleted-without-title, PullRequestEvent generic-action-
without-title, and review_requested-with-title-but-no-reviewer. Only the
unreachable format_display exception handler remains uncovered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers from_github_api field mapping, datetime parsing, labels/assignees
lists, is_pull_request detection, format_display for all states
(open/closed/merged/draft), and _format_relative_time with singular and
plural forms for all time buckets.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers from_github_api field mapping, format_size for all buckets
including GB, format_display download count singular/plural,
get_status_label combinations, _format_relative_time including weeks and
date fallback, format_display name-vs-tag branching, and asset list
parsing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Repository: from_github_api field mapping, format_display with/without
description and truncation, format_single_line, _format_relative_time
singular/plural for all buckets.

UserProfile: from_github_api field mapping, display_name fallback to
login, format_display with/without name and bio, bio truncation at 50
chars, newline replacement, _format_relative_time singular/plural.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
conftest.py adds the project root to sys.path so top-level modules
(config, repo_sync, etc.) are importable from the tests/ subdirectory.
pytest.ini sets --basetemp=.pytest_tmp to avoid Windows temp-dir
permission errors when using the tmp_path fixture.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 tests covering: _load() reads/misses/invalid JSON, save() creates
files and subdirs, roundtrips, autosave on setitem/delitem, close(),
config_file path in portable and non-portable modes, is_portable_mode()
detection and caching, get_config_home() platform dispatch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…mocked

36 tests covering: _ensure_defaults, get/set_repo_config, get_enabled_repos,
sync_all_enabled (global disable + per-repo dispatch), sync_one (error paths
for missing/non-git path, success with fetch+pull), _run_git (success/failure),
_run_git_allow_fail, _maybe_push (dirty/detached/not-ahead/ahead/no-upstream),
_run_lfs_sync (disabled/missing/happy-path), RepoSyncResult dataclass.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… HTTP

40 tests: username/display_name properties, last error management, get_repos
(pagination, error, empty page), get_repo, get_issues (PR filtering, pagination),
get/create/update/close/reopen issue, issue comments (get/create/delete),
_graphql (success, HTTP error, GraphQL errors, None data, exception).
Uses object.__new__ to bypass wx-dependent __init__.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
24 tests: verify all major modules import cleanly (models, config,
repo_sync, github_api), expose expected class/method names, constants
are correct types, and core classes instantiate from minimal data
without crashing. wx is stubbed so github_api can be imported
without a running GUI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

1 participant