test: add idle-resumed and light-tier coverage for report helpers (#1162)#1163
Open
test: add idle-resumed and light-tier coverage for report helpers (#1162)#1163
Conversation
) Add three tests to close coverage gaps in _compute_session_totals and _estimate_premium_cost: - TestComputeSessionTotals: idle-resumed state (is_active=True, has_shutdown_metrics=True, has_active_period_stats=False) verifies the else branch returns full counts without subtraction. - TestEstimatePremiumCost: light-tier 0.33× multiplier (claude-haiku-4.5) verifies fractional rounding at 1, 3, and 10 calls. - TestRenderLiveSessions: end-to-end render check that the Est. Cost column shows ~1 for a haiku session with 3 active model calls. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds focused regression tests for the reporting layer in copilot_usage, closing coverage gaps around idle-resumed session aggregation and light-tier premium-cost estimation/rendering.
Changes:
- Add a
render_live_sessionstest for a light-tierclaude-haiku-4.5session showing the expected estimated cost. - Add direct
_estimate_premium_costassertions for 0.33× multiplier rounding behavior. - Add
_compute_session_totalscoverage for idle-resumed sessions where shutdown-only totals must not subtract inactiveactive_*counters.
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 #1162
Changes
Adds three tests to close coverage gaps identified in the issue:
Gap 1 —
_compute_session_totals: idle-resumed statetest_shutdown_only_no_subtraction_for_idle_resumed_session— covers the untestedelsebranch whenshutdown_only=True,has_shutdown_metrics=True, buthas_active_period_stats()returnsFalse(allactive_*counters are 0,last_resume_timeisNone). Asserts fullmodel_callsanduser_messagesare returned without subtraction.Gap 2 —
_estimate_premium_cost: light-tier 0.33× multipliertest_light_tier_model_uses_fractional_multiplier— exercisesclaude-haiku-4.5(0.33× multiplier) at 1, 3, and 10 calls, verifying theround()rounding behavior that was previously untested:round(0.33) = 0→"~0"round(0.99) = 1→"~1"round(3.3) = 3→"~3"Companion —
render_live_sessionslight-tier Est. Cost columntest_est_cost_light_tier_model— end-to-end render test that verifies aclaude-haiku-4.5session with 3 active model calls shows"~1"in the Est. Cost column.Warning
The following domains were blocked by the firewall during workflow execution:
astral.shpypi.orgreleaseassets.githubusercontent.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.