Skip to content

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

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

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
Contributor

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
@boyangsvl boyangsvl self-assigned this Jun 3, 2026
copybara-service Bot pushed a commit that referenced this pull request Jun 3, 2026
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.

Merge #5948

Change-Id: If05c49f82c7bb73d8c39be548434672497a770c2
@adk-bot

adk-bot commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

Thank you @Koushik-Salammagari for your contribution! 🎉

Your changes have been successfully imported and merged via Copybara in commit 96381ab.

Closing this PR as the changes are now in the main branch.

@adk-bot adk-bot added the merged [Status] This PR is merged label Jun 3, 2026
@adk-bot adk-bot closed this Jun 3, 2026
nagug pushed a commit to vidaiUK/adk-python that referenced this pull request Jun 5, 2026
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.

Merge google/adk-python#5948

Change-Id: If05c49f82c7bb73d8c39be548434672497a770c2
copybara-service Bot pushed a commit that referenced this pull request Jun 8, 2026
Port of GitHub PR: #5948

Adds unit tests for Event class helper methods:
- is_final_response()
- get_function_calls()
- get_function_responses()
- has_trailing_code_execution_result()
- automatic ID generation

Co-authored-by: Yifan Wang <wanyif@google.com>
PiperOrigin-RevId: 927411791
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 merged [Status] This PR is merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants