Skip to content

test: add coverage for pure active session with no model_metrics (#78)#79

Closed
microsasa wants to merge 2 commits intomainfrom
fix/78-pure-active-no-metrics-tests-f7c28235f8a0164b
Closed

test: add coverage for pure active session with no model_metrics (#78)#79
microsasa wants to merge 2 commits intomainfrom
fix/78-pure-active-no-metrics-tests-f7c28235f8a0164b

Conversation

@microsasa
Copy link
Owner

Summary

Adds two missing tests to TestRenderCostView that exercise the branch A + branch B combination in render_cost_view — a session where model_metrics={} (no shutdown data) and is_active=True (just started).

Tests added

Test Assertion
test_pure_active_session_no_metrics_shows_both_rows Placeholder row () AND ↳ Since last shutdown row both appear
test_pure_active_no_metrics_grand_total_includes_active_tokens Grand total output tokens includes active_output_tokens (formatted as 1.5K)

Regression coverage

These tests guard against:

  • Accidentally nesting if s.is_active: inside if s.model_metrics:, which would silently lose the "Since last shutdown" row for pure-active sessions
  • Removing grand_output += s.active_output_tokens from the active block, which would under-count output tokens

CI

All 382 tests pass. Coverage: 96.64% (threshold: 80%).

Closes #78

Generated by Issue Implementer ·

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • astral.sh

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "astral.sh"

See Network Configuration for more information.

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>
Copilot AI review requested due to automatic review settings March 15, 2026 17:51
@microsasa microsasa added the aw Created by agentic workflow label Mar 15, 2026
@microsasa microsasa enabled auto-merge March 15, 2026 17:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_tokens for pure-active, no-metrics sessions.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1361 to +1364
output = _capture_cost_view([session])
assert "Grand Total" in output
# 1500 output tokens → formatted as "1.5K"
assert "1.5K" in output
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions
Copy link
Contributor

Commit pushed: bf1e555

Generated by Review Responder

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>
@microsasa
Copy link
Owner Author

Closing for fresh implementer run with fixed quality-gate pipeline on main.

@microsasa microsasa closed this Mar 15, 2026
auto-merge was automatically disabled March 15, 2026 18:23

Pull request was closed

@microsasa microsasa deleted the fix/78-pure-active-no-metrics-tests-f7c28235f8a0164b branch March 15, 2026 18:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow review-response-attempted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][test audit] render_cost_view untested for pure active session with no model_metrics

2 participants