test: add direct tests for _build_event_details TOOL_EXECUTION_COMPLETE branch (#1180)#1181
Open
test: add direct tests for _build_event_details TOOL_EXECUTION_COMPLETE branch (#1180)#1181
_build_event_details TOOL_EXECUTION_COMPLETE branch (#1180)#1181Conversation
…TE branch (#1180) Add TestBuildEventDetailsToolExecutionComplete class covering: - Success + tool name + model (joined output assertion) - Failure indicator (✗ present, ✓ absent) - Model absent (None and empty string) - Tool name absent (no telemetry, no leading separator) - Malformed data guard (ValidationError → empty string) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds direct unit tests for the EventType.TOOL_EXECUTION_COMPLETE branch of _build_event_details in copilot_usage.render_detail, closing the test gap identified in #1180.
Changes:
- Adds
TestBuildEventDetailsToolExecutionCompletewith focused assertions on the composed detail string (tool name, success/failure indicator, optional model). - Covers malformed event payload behavior to ensure
_build_event_detailsreturns""when validation fails.
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 #1180
Summary
Adds
TestBuildEventDetailsToolExecutionCompleteintests/copilot_usage/test_render_detail.pywith direct tests for theTOOL_EXECUTION_COMPLETEbranch of_build_event_details.Tests Added
test_success_with_tool_name_and_modelsuccess=True, tool_name from telemetry, model present → exact joined output"bash ✓ model=claude-sonnet-4"test_failure_indicatorsuccess=False, no telemetry →✗present,✓absenttest_model_absentmodel=None→ nomodel=in outputtest_model_empty_stringmodel=""→ nomodel=in outputtest_tool_name_absent_no_telemetrytoolTelemetry=None→ detail starts with indicator, no leading separatortest_malformed_data_returns_emptyValidationError→ returns""Each test calls
_build_event_details(ev)directly with precise string assertions, following the same pattern used byTestBuildEventDetailsSessionShutdownandTestBuildEventDetailsUserMessage.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.