Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions tests/copilot_usage/test_render_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
ToolTelemetry,
)
from copilot_usage.render_detail import (
_build_event_details,
_extract_tool_name,
_render_code_changes,
_render_recent_events,
Expand Down Expand Up @@ -608,3 +609,41 @@ def test_multi_model_shutdown_via_full_render(self) -> None:
row = next(line for line in output.splitlines() if "2025-01-01 01:00" in line)
assert re.search(r"\b7\b", row) # total model calls = 3 + 4
assert re.search(r"\b800\b", row) # total output tokens = 500 + 300


# ---------------------------------------------------------------------------
# Issue #860 — untested branch in _build_event_details
# ---------------------------------------------------------------------------


class TestBuildEventDetailsUntestedBranches:
"""Cover untested branches in _build_event_details:

1. SESSION_SHUTDOWN with falsy shutdownType → returns "".
2. TOOL_EXECUTION_COMPLETE with truthy model → includes model=<value>.
"""
Comment on lines +619 to +624
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

These new direct _build_event_details tests look redundant with existing coverage in tests/copilot_usage/test_report.py::TestBuildEventDetails (SESSION_SHUTDOWN empty/default cases) and TestRenderRecentEvents.test_tool_execution_shows_name_and_success (TOOL_EXECUTION_COMPLETE with model=). Consider deleting this whole block (and the new _build_event_details import) or consolidating all _build_event_details coverage into a single test module to avoid duplicated maintenance surface and conflicting expectations if formatting changes.

Copilot uses AI. Check for mistakes.

def test_session_shutdown_with_falsy_shutdown_type(self) -> None:
"""SESSION_SHUTDOWN with shutdownType='' returns empty string."""
ev = SessionEvent(
type=EventType.SESSION_SHUTDOWN,
data={"totalPremiumRequests": 5},
)
detail = _build_event_details(ev)
assert detail == ""

def test_tool_execution_complete_with_model(self) -> None:
"""TOOL_EXECUTION_COMPLETE with model field includes model=<value> in detail."""
ev = SessionEvent(
type=EventType.TOOL_EXECUTION_COMPLETE,
data={
"toolCallId": "t1",
"success": True,
"model": "claude-sonnet-4",
"toolTelemetry": {"properties": {"tool_name": "bash"}},
},
)
detail = _build_event_details(ev)
assert "model=claude-sonnet-4" in detail
assert "bash" in detail
assert "✓" in detail
Comment on lines +635 to +649
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

This TOOL_EXECUTION_COMPLETE model detail branch is already exercised via the full render pipeline in tests/copilot_usage/test_report.py::TestRenderRecentEvents.test_tool_execution_shows_name_and_success (it builds a tool event with model: gpt-4 and asserts model=gpt-4 is rendered). Since _render_recent_events calls _build_event_details, this test is redundant and adds duplicated expectations that can become brittle if formatting changes; consider deleting it or moving all _build_event_details assertions into the existing TestBuildEventDetails block in test_report.py.

Copilot uses AI. Check for mistakes.
Loading