test: add coverage for pure active session with no model_metrics (#78)#79
test: add coverage for pure active session with no model_metrics (#78)#79
Conversation
Add two tests to TestRenderCostView exercising branch A + branch B: - test_pure_active_session_no_metrics_shows_both_rows: verifies placeholder row AND 'Since last shutdown' row appear together - test_pure_active_no_metrics_grand_total_includes_active_tokens: verifies grand total output tokens includes active_output_tokens Closes #78 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds missing regression tests around render_cost_view for the edge case where a session is active but has no model_metrics yet, ensuring both placeholder (no-metrics) and active (“Since last shutdown”) behaviors stay covered.
Changes:
- Add a test asserting a pure-active, no-metrics session renders both the placeholder row and the “Since last shutdown” row.
- Add a test intended to ensure the Grand Total includes
active_output_tokensfor pure-active, no-metrics sessions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tests/copilot_usage/test_report.py
Outdated
| output = _capture_cost_view([session]) | ||
| assert "Grand Total" in output | ||
| # 1500 output tokens → formatted as "1.5K" | ||
| assert "1.5K" in output |
There was a problem hiding this comment.
Good catch — the original assert "1.5K" in output would still pass even if grand_output += s.active_output_tokens were removed, since the active row itself contains 1.5K.
Fixed by extracting the Grand Total row with a regex (stripping ANSI codes first) and asserting the output-tokens column specifically equals "1.5K", matching the pattern used in test_resumed_session_no_double_count.
Generated by Review Responder for issue #79
|
Commit pushed:
|
Strengthen test_pure_active_no_metrics_grand_total_includes_active_tokens to extract the Grand Total row via regex and assert the output tokens column specifically equals '1.5K', matching the pattern used in test_resumed_session_no_double_count. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Closing for fresh implementer run with fixed quality-gate pipeline on main. |
Pull request was closed
Summary
Adds two missing tests to
TestRenderCostViewthat exercise the branch A + branch B combination inrender_cost_view— a session wheremodel_metrics={}(no shutdown data) andis_active=True(just started).Tests added
test_pure_active_session_no_metrics_shows_both_rows—) AND↳ Since last shutdownrow both appeartest_pure_active_no_metrics_grand_total_includes_active_tokensactive_output_tokens(formatted as1.5K)Regression coverage
These tests guard against:
if s.is_active:insideif s.model_metrics:, which would silently lose the "Since last shutdown" row for pure-active sessionsgrand_output += s.active_output_tokensfrom the active block, which would under-count output tokensCI
All 382 tests pass. Coverage: 96.64% (threshold: 80%).
Closes #78
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.