Skip to content

test: cover untested branches in render_detail.py (#1058)#1060

Merged
microsasa merged 3 commits intomainfrom
fix/1058-render-detail-untested-branches-d1b1a5837d4bfb4b
Apr 23, 2026
Merged

test: cover untested branches in render_detail.py (#1058)#1060
microsasa merged 3 commits intomainfrom
fix/1058-render-detail-untested-branches-d1b1a5837d4bfb4b

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #1058

Adds direct test coverage for three untested branches in src/copilot_usage/render_detail.py:

Gap 1 — _build_event_details: SESSION_SHUTDOWN arm

New TestBuildEventDetailsSessionShutdown class with three tests:

  • test_non_empty_shutdown_type — verifies "type=routine" output
  • test_empty_shutdown_type — verifies empty string output
  • test_malformed_data_returns_empty — int shutdownType triggers ValidationError""

Gap 2 — _render_shutdown_cycles: ts=None path

New TestRenderShutdownCyclesNoneTimestamp class:

  • test_none_timestamp_renders_dash(None, sd) tuple renders "—" in Date column

Gap 3 — _truncate: max_len ≤ 0 guard

Parametrized test covering max_len ∈ {0, -1, -100}:

  • test_truncate_non_positive_max_len_returns_empty — all return ""

Notes

  • No source changes — test-only additions
  • All tests follow existing patterns in the file (same imports, helpers, style)
  • Environment could not run make check locally (network-blocked sandbox; uv not available), but CI will validate

Warning

⚠️ Firewall blocked 2 domains

The following domains were blocked by the firewall during workflow execution:

  • astral.sh
  • pypi.org

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

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

See Network Configuration for more information.

Generated by Issue Implementer · ● 14.9M ·

Add tests for three untested code paths:

- TestBuildEventDetailsSessionShutdown: SESSION_SHUTDOWN arm of
  _build_event_details with non-empty type, empty type, and malformed
  data sub-cases
- TestRenderShutdownCyclesNoneTimestamp: ts=None path in
  _render_shutdown_cycles renders '—' in Date column
- test_truncate_non_positive_max_len_returns_empty: parametrized test
  for _truncate max_len <= 0 guard with values {0, -1, -100}

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 08:28
@microsasa microsasa added the aw Created by agentic workflow label Apr 23, 2026
@microsasa microsasa enabled auto-merge April 23, 2026 08:28
Copy link
Copy Markdown

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 targeted unit tests to increase branch coverage for private helpers in src/copilot_usage/render_detail.py, addressing gaps identified in issue #1058 without modifying production code.

Changes:

  • Adds tests for _build_event_details() handling of EventType.SESSION_SHUTDOWN (including empty/non-empty shutdown types).
  • Adds a test covering _render_shutdown_cycles() when a shutdown cycle timestamp is None (renders "—").
  • Adds a parametrized test covering _truncate()’s max_len <= 0 guard.

Comment thread tests/copilot_usage/test_render_detail.py Outdated
@microsasa microsasa added the aw-review-response-1 Review response round 1 label Apr 23, 2026
Replace inline (StringIO, Console) setup with existing _buf_console()
helper in TestRenderShutdownCyclesNoneTimestamp to reduce duplication
and keep console configuration consistent across tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: 5f9ff62

Generated by Review Responder

@microsasa microsasa added the aw-review-response-2 Review response round 2 label Apr 23, 2026
Replace inline StringIO/Console setup in TestRenderCodeChanges with the
existing _buf_console() helper to keep console configuration consistent
across tests and reduce duplication.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: 8102d44

Generated by Review Responder

Copilot AI review requested due to automatic review settings April 23, 2026 08:46
Copy link
Copy Markdown

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 23, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions Bot left a comment

Choose a reason for hiding this comment

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

Quality Gate: APPROVE

Low-impact, test-only PR adding coverage for three previously untested branches in render_detail.py:

  • _build_event_details SESSION_SHUTDOWN arm
  • _render_shutdown_cycles with ts=None
  • _truncate with max_len ≤ 0

Also refactors 5 existing tests to consistently use the _buf_console() helper. All 9 CI checks pass. No source changes. Auto-approving for merge.

@microsasa microsasa merged commit 1ebaacd into main Apr 23, 2026
9 checks passed
@microsasa microsasa deleted the fix/1058-render-detail-untested-branches-d1b1a5837d4bfb4b branch April 23, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR aw-review-response-1 Review response round 1 aw-review-response-2 Review response round 2

Projects

None yet

2 participants