Skip to content

test: add coverage for rendering and parser edge cases#42

Merged
microsasa merged 1 commit intomainfrom
test/coverage-gaps
Mar 14, 2026
Merged

test: add coverage for rendering and parser edge cases#42
microsasa merged 1 commit intomainfrom
test/coverage-gaps

Conversation

@microsasa
Copy link
Owner

Closes #18
Closes #19

Adds tests for untested branches in report.py and parser.py:

Issue #18 — Session detail rendering:

  • _build_event_details: tool failure, no telemetry, no tool_name, shutdown, zero tokens
  • _event_type_label: all match arms (tool start, turn end, session start/end, fallback)
  • _format_relative_time: hours branch
  • _format_detail_duration: hours and seconds branches
  • Integration test for TOOL_EXECUTION_START and ASSISTANT_TURN_END labels

Issue #19 — Parser utilities:

  • _extract_session_name: plain text, empty file, OSError edge cases
  • _aggregate_model_metrics: same model merging, different models, empty list, empty metrics
  • get_all_sessions: OSError recovery (graceful skip)
  • _filter_sessions: None start_time exclusion
  • _render_totals: singular grammar

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com

Copy link

Copilot AI left a 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 closes #18 and #19 by adding targeted unit/integration tests to cover previously untested branches in copilot_usage report rendering and parser utilities, reducing regression risk for user-visible output and filesystem edge cases.

Changes:

  • Add direct unit tests for report.py helpers (_build_event_details, _event_type_label, _format_relative_time, _format_detail_duration, _aggregate_model_metrics, _filter_sessions) plus an integration assertion for session-detail labels.
  • Add parser tests for _extract_session_name edge cases and get_all_sessions behavior when parse_events raises OSError.
  • Adjust test modules’ type-checking configuration to allow private helper testing (# pyright: reportPrivateUsage=false).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/copilot_usage/test_report.py Adds coverage for report rendering helper branches and an integration check for recent-event labels and totals grammar.
tests/copilot_usage/test_parser.py Adds coverage for session name extraction edge cases and get_all_sessions OSError skip behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@microsasa microsasa force-pushed the test/coverage-gaps branch from 8589e19 to e47b420 Compare March 14, 2026 18:52
Add tests for untested branches in report.py and parser.py:

Issue #18 — Session detail rendering:
- _build_event_details: tool failure, no telemetry, no tool_name, shutdown, zero tokens
- _event_type_label: all match arms (tool start, turn end, session start/end, fallback)
- _format_relative_time: hours branch
- _format_detail_duration: hours and seconds branches
- Integration test for TOOL_EXECUTION_START and ASSISTANT_TURN_END labels

Issue #19 — Parser utilities:
- _extract_session_name: plain text, empty file, OSError edge cases
- _aggregate_model_metrics: same model merging, different models, empty list, empty metrics
- get_all_sessions: OSError recovery (graceful skip)
- _filter_sessions: None start_time exclusion
- _render_totals: singular grammar ("1 session", "1 premium request")

Closes #18
Closes #19

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa force-pushed the test/coverage-gaps branch from e47b420 to 860c4de Compare March 14, 2026 19:01
@microsasa microsasa merged commit d781bc6 into main Mar 14, 2026
4 checks passed
@microsasa microsasa deleted the test/coverage-gaps branch March 16, 2026 07:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants