Conversation
…range (#126) Add three new tests to close assertion gaps identified in issue #126: - test_resumed_session_grand_output_includes_historical_and_active: Dedicated test that grand output tokens = historical + active for resumed sessions (1000 + 200 = 1200 → "1.2K"). - test_mixed_sessions_grand_total: Verifies grand output sums metrics-output from a completed session plus active_output from an active-no-metrics session (2000 + 500 = 2500 → "2.5K"). - test_summary_header_single_session_same_date_both_ends: Asserts that with a single session the date appears on both ends of the date range subtitle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds targeted tests to close assertion gaps around summary date-range rendering and cost-view grand total output-token aggregation, strengthening regression coverage for copilot_usage.report rendering.
Changes:
- Add a single-session summary header test ensuring the same date appears on both ends of the rendered date range.
- Add cost-view tests asserting correct grand-total output-token aggregation for (a) resumed sessions with both historical + active tokens and (b) mixed session types (completed-with-metrics + active-no-metrics).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Quality Gate: APPROVED ✅
Code Quality: Good — three well-structured tests with meaningful assertions, clear docstrings, and documented math. Tests follow existing patterns in TestReportCoverageGaps and TestRenderCostView.
Impact: LOW — test-only change (60 lines added to tests/copilot_usage/test_report.py, no production code modified).
Tests added:
test_resumed_session_grand_output_includes_historical_and_active— catches regressions in historical+active token aggregationtest_mixed_sessions_grand_total— catches regressions in cross-session-type grand totaltest_summary_header_single_session_same_date_both_ends— catches single-session date range bugs
Low-impact test addition closing assertion gaps from #126. Auto-approving for merge.
- Remove duplicate test_resumed_session_grand_output_includes_historical_and_active (already covered by test_resumed_session_no_double_count) - Move test_summary_header_single_session_same_date_both_ends to TestRenderSummary class to match PR description Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Commit pushed:
|
Closes #126
Changes
Adds three new tests in
tests/copilot_usage/test_report.pyto close assertion gaps identified in issue #126:TestRenderCostViewtest_resumed_session_grand_output_includes_historical_and_active— Dedicated test verifying that grand total output tokens = historical (frommodel_metrics) + active (active_output_tokens) for a resumed session. Asserts1000 + 200 = 1200 → "1.2K"appears in the grand total.test_mixed_sessions_grand_total— Combines a completed session with metrics (outputTokens=2000) and an active session with no metrics (active_output_tokens=500), asserting the grand total shows"2.5K"(2500 tokens).TestRenderSummarytest_summary_header_single_session_same_date_both_ends— With a single session, asserts the date appears at least twice in the output (both ends of theearliest → latestdate range subtitle).Regression scenarios covered
grand_output += s.active_output_tokensfor resumed sessions → caught by first testCI
All 407 tests pass, 97.97% coverage (≥80% threshold met). Ruff, pyright, and bandit checks clean.