Skip to content

test: cover untested cli.py branches (#59)#91

Merged
microsasa merged 2 commits intomainfrom
fix/59-untested-cli-branches-742079b38a0dec64
Mar 15, 2026
Merged

test: cover untested cli.py branches (#59)#91
microsasa merged 2 commits intomainfrom
fix/59-untested-cli-branches-742079b38a0dec64

Conversation

@microsasa
Copy link
Owner

Closes #59

Adds 15 new tests covering five distinct untested code paths in cli.py:

1. _ensure_aware unit tests

  • None → returns None
  • Already timezone-aware → returned unchanged
  • Naive datetime → gets UTC attached
  • Non-UTC aware datetime → returned unchanged (identity check)

2. Uppercase interactive commands

  • Q exits the loop (same as q)
  • C shows cost view (same as c)
  • R refreshes data (same as r)

3. _show_session_by_index with events_path=None

  • Creates a SessionSummary with events_path=None and asserts the "No events path" error message

4. Group-level --path propagation

  • Tests all four subcommands (summary, session, cost, live) with --path specified at the group level instead of the subcommand level

5. Auto-refresh branches in _interactive_loop

  • Captures the change_event via _start_observer interception
  • Tests auto-refresh while on home view (verifies _draw_home called ≥2 times)
  • Tests auto-refresh while on cost view (verifies render_cost_view called ≥2 times)
  • Tests auto-refresh while on detail view with detail_idx set (verifies _show_session_by_index called ≥2 times)

Results

  • All 398 tests pass with no regressions
  • Coverage for cli.py: 92% → 96%
  • Overall coverage: 97.04% → 97.97%
  • All lint/type checks pass (ruff, pyright)

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"

See Network Configuration for more information.

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>
@microsasa microsasa added the aw Created by agentic workflow label Mar 15, 2026
Copilot AI review requested due to automatic review settings March 15, 2026 19:43
@microsasa microsasa enabled auto-merge March 15, 2026 19:43
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

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_aware for None, naive, and aware datetimes.
  • Add interactive-mode tests for uppercase commands and additional edge cases (events_path=None, group --path propagation).
  • Add tests covering the auto-refresh branches in _interactive_loop across home/cost/detail views.

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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 --path propagation, 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.

@github-actions
Copy link
Contributor

Commit pushed: 6cda280

Generated by Review Responder

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa merged commit a17638f into main Mar 15, 2026
13 checks passed
@microsasa microsasa deleted the fix/59-untested-cli-branches-742079b38a0dec64 branch March 15, 2026 19:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

2 participants