test: add coverage for rendering and parser edge cases#42
Merged
Conversation
There was a problem hiding this comment.
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.pyhelpers (_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_nameedge cases andget_all_sessionsbehavior whenparse_eventsraisesOSError. - 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.
8589e19 to
e47b420
Compare
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>
e47b420 to
860c4de
Compare
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.
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 branchesIssue #19 — Parser utilities:
_extract_session_name: plain text, empty file, OSError edge cases_aggregate_model_metrics: same model merging, different models, empty list, empty metricsget_all_sessions: OSError recovery (graceful skip)_filter_sessions: None start_time exclusion_render_totals: singular grammarCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com