-
Notifications
You must be signed in to change notification settings - Fork 1
test(render_detail): cover untested _build_event_details branches (#860)
#865
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
60582b0
d02d67d
f693d2b
9d397ca
2c1cbcb
3aeb7ea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| ToolTelemetry, | ||
| ) | ||
| from copilot_usage.render_detail import ( | ||
| _build_event_details, | ||
| _extract_tool_name, | ||
| _render_code_changes, | ||
| _render_recent_events, | ||
|
|
@@ -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
|
||
|
|
||
| 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={ | ||
microsasa marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "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
|
||
Uh oh!
There was an error while loading. Please reload this page.