test: assert Cache Read column in _render_model_table tests (#1196)#1198
Open
test: assert Cache Read column in _render_model_table tests (#1196)#1198
Conversation
Add test_cache_read_column_present and test_cache_read_zero_renders to TestRenderModelTable. Also update test_cache_write_column_present to assert Cache Read header and 8.0K value (the fixture already sets cacheReadTokens=8_000). Closes #1196 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR strengthens copilot_usage.report._render_model_table test coverage by ensuring the Cache Read column header and its formatted values are asserted, preventing regressions where the column is dropped or rendered incorrectly.
Changes:
- Extends the existing Cache Write test to also assert Cache Read header and value formatting (
8.0K). - Adds a dedicated test asserting Cache Read renders and formats correctly when non-zero.
- Adds a test intended to verify Cache Read still renders when the value is zero.
Comment on lines
+3560
to
+3574
| usage=TokenUsage( | ||
| inputTokens=100, | ||
| outputTokens=50, | ||
| cacheReadTokens=0, | ||
| cacheWriteTokens=0, | ||
| ), | ||
| ) | ||
| }, | ||
| ) | ||
| buf = StringIO() | ||
| console = Console(file=buf, force_terminal=True, width=200) | ||
| _render_model_table(console, [session]) | ||
| output = buf.getvalue() | ||
| assert "Cache Read" in output | ||
| assert "0" 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.
Summary
TestRenderModelTableonly asserted the Cache Write column but never verified that the Cache Read column header and formatted values appear in_render_model_tableoutput.Changes
test_cache_write_column_present— now also asserts"Cache Read" in outputand"8.0K" in output(the fixture already setscacheReadTokens=8_000)test_cache_read_column_present(new) — dedicated test withcacheReadTokens=8_000, asserts header and"8.0K"test_cache_read_zero_renders(new) — verifies the column header still appears whencacheReadTokens=0and that"0"is renderedThese additions ensure any regression that drops or silently zeroes the Cache Read column will be caught.
Closes #1196
Warning
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.