test: cover untested cli.py branches (#59)#91
Merged
Conversation
Add tests for five untested code paths in cli.py: 1. _ensure_aware: parametrized tests for None, aware, and naive datetimes 2. Uppercase interactive commands: Q, C, R produce same outcomes as lowercase 3. _show_session_by_index with events_path=None: asserts error message 4. Group-level --path propagation: all four subcommands inherit group path 5. Auto-refresh branches: change_event triggers re-render in home, cost, and detail views via captured observer event Coverage for cli.py increases from 92% to 96%. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Expands the CLI test suite to cover previously untested branches (notably Issue #59) around datetime handling, interactive-mode command variants, group-level --path propagation, and interactive auto-refresh behavior.
Changes:
- Add unit tests for
_ensure_awareforNone, naive, and aware datetimes. - Add interactive-mode tests for uppercase commands and additional edge cases (
events_path=None, group--pathpropagation). - Add tests covering the auto-refresh branches in
_interactive_loopacross home/cost/detail views.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
15 tasks
Contributor
There was a problem hiding this comment.
Quality Gate: APPROVED ✅
Evaluation summary:
- Scope: Test-only changes — 296 lines added to
tests/copilot_usage/test_cli.py, zero production code modified - Impact: LOW (test additions only)
- Code quality: Good — 15 meaningful tests covering 5 distinct untested branches in
cli.py(_ensure_aware, uppercase interactive commands,events_path=None, group-level--pathpropagation, auto-refresh branches). Tests use proper pytest patterns (parametrize, monkeypatch, tmp_path) and include clear docstrings. - CI: All checks passing (
check✅,CodeQL✅,analyze✅) - Copilot review: One minor cosmetic suggestion about timezone construction — not a blocker.
Low-impact test addition with good coverage. Auto-approving for merge.
Contributor
|
Commit pushed:
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 15, 2026
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 #59
Adds 15 new tests covering five distinct untested code paths in
cli.py:1.
_ensure_awareunit testsNone→ returnsNone2. Uppercase interactive commands
Qexits the loop (same asq)Cshows cost view (same asc)Rrefreshes data (same asr)3.
_show_session_by_indexwithevents_path=NoneSessionSummarywithevents_path=Noneand asserts the "No events path" error message4. Group-level
--pathpropagationsummary,session,cost,live) with--pathspecified at the group level instead of the subcommand level5. Auto-refresh branches in
_interactive_loopchange_eventvia_start_observerinterception_draw_homecalled ≥2 times)render_cost_viewcalled ≥2 times)detail_idxset (verifies_show_session_by_indexcalled ≥2 times)Results
cli.py: 92% → 96%Warning
The following domain was blocked by the firewall during workflow execution:
astral.shTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.