test: add pure-active empty-metrics coverage for render_summary (#1197)#1199
Open
test: add pure-active empty-metrics coverage for render_summary (#1197)#1199
Conversation
Add two tests to TestRenderSummary exercising a pure-active session
(never shut down) where model_metrics={} but active_output_tokens > 0:
1. test_pure_active_empty_metrics_shows_active_output_tokens — verifies
the Totals panel correctly shows active_output_tokens (1.5K) via
total_output_tokens when model_metrics is empty.
2. test_pure_active_empty_metrics_no_model_table — verifies
_aggregate_model_metrics returns {} and no per-model breakdown
table appears in the output.
Closes #1197
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds targeted unit-test coverage for copilot_usage.report.render_summary when rendering a pure-active session that has model_metrics={} but non-zero active_output_tokens, ensuring totals/token counting and model-table behavior don’t regress.
Changes:
- Add a
TestRenderSummarycase assertingactive_output_tokenscontribute to totals whenmodel_metricsis empty. - Add a
TestRenderSummarycase asserting no per-model breakdown table is rendered whenmodel_metricsis empty.
| output = _capture_summary([session]) | ||
| # _aggregate_model_metrics returns {} for empty model_metrics, | ||
| # so no per-model breakdown table should appear. | ||
| assert "claude-" not in output |
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 #1197
Summary
Adds two tests to
TestRenderSummaryexercising a pure-active session (never shut down) wheremodel_metrics={}butactive_output_tokens > 0.Tests Added
test_pure_active_empty_metrics_shows_active_output_tokens— verifies the Totals panel correctly showsactive_output_tokens(1.5K) viatotal_output_tokenswhenmodel_metricsis empty. Guards against regressions wheretotal_output_tokensmight be incorrectly short-circuited to return 0 for empty-metrics sessions.test_pure_active_empty_metrics_no_model_table— verifies_aggregate_model_metricsreturns{}for emptymodel_metricsand no per-model breakdown table appears in therender_summaryoutput. Guards against regressions where a synthetic model row might be incorrectly added.Regression Scenarios Covered
total_output_tokensto not returnactive_output_tokenswhenmodel_metricsis empty → test 1 catches it_aggregate_model_metricsto synthesize a fallback model row for empty-metrics sessions → test 2 catches itWarning
The following domains were blocked by the firewall during workflow execution:
astral.shpypi.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.