Skip to content

test(events): add unit tests for Event helper methods#5948

Open
Koushik-Salammagari wants to merge 2 commits into
google:mainfrom
Koushik-Salammagari:test/event-helper-methods-coverage
Open

test(events): add unit tests for Event helper methods#5948
Koushik-Salammagari wants to merge 2 commits into
google:mainfrom
Koushik-Salammagari:test/event-helper-methods-coverage

Conversation

@Koushik-Salammagari
Copy link
Copy Markdown

Link to Issue or Description of Change

Or, if no issue exists, describe the change:

Problem:
The Event class's helper methods — is_final_response(), get_function_calls(), get_function_responses(), has_trailing_code_execution_result(), and automatic id generation in model_post_init — had no dedicated unit tests. They were only exercised incidentally through higher-level tests, and there was no tests/unittests/events/ package at all. This left several branches (early-return overrides, empty-content edge cases) without direct coverage.

Solution:
Add tests/unittests/events/test_event.py with focused, isolated unit tests for these methods, including edge cases:

  • is_final_response() — plain/empty events are final; function-call/response, partial, and trailing code-execution results are not final; skip_summarization and long_running_tool_ids early-return overrides.
  • get_function_calls() / get_function_responses() — ordering, no-content, empty-parts, and text-only cases.
  • has_trailing_code_execution_result() — last vs. non-last part, no-content, and empty-parts cases.
  • id auto-generation — auto-assigned when missing, unique across events, and preserved when explicitly provided.

These are pure-logic tests with no external dependencies; no runtime behavior is changed.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
$ pytest tests/unittests/events/test_event.py -q
22 passed, 5 warnings in 1.02s

Manual End-to-End (E2E) Tests:

N/A — this is a test-only change and does not modify any runtime behavior.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Add a dedicated test module for the Event class, which previously had
only incidental coverage. Covers is_final_response(), get_function_calls(),
get_function_responses(), has_trailing_code_execution_result(), and
automatic id generation, including edge cases such as events with no
content, empty parts lists, and the skip_summarization /
long_running_tool_ids early-return overrides.
@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core [Component] This issue is related to the core interface and implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants