Skip to content

test(sessions): add unit tests for _session_util#6206

Open
Koushik-Salammagari wants to merge 1 commit into
google:mainfrom
Koushik-Salammagari:test/session-util-coverage
Open

test(sessions): add unit tests for _session_util#6206
Koushik-Salammagari wants to merge 1 commit into
google:mainfrom
Koushik-Salammagari:test/session-util-coverage

Conversation

@Koushik-Salammagari

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

Description of the change (no existing issue):

Problem:
The google.adk.sessions._session_util module had no dedicated unit-test
coverage. Its extract_state_delta helper contains prefix-routing logic
(app:, user:, temp:) that is used by session services to split a flat
state dict into app/user/session deltas, and a regression here would silently
corrupt persisted session state.

Solution:
Add a focused, test-only module covering both functions and their edge cases.
No production code is changed.

Coverage added:

  • decode_modelNone passthrough, decoding a dict into a model instance,
    and raising on invalid data.
  • extract_state_deltaapp:/user: prefixed keys routed to their buckets
    with the prefix stripped, temp: keys skipped entirely, unprefixed keys
    routed to the session bucket, empty and None state, and a mixed-key case.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.
$ pytest tests/unittests/sessions/test__session_util.py -q
...
10 passed in 1.03s

Manual End-to-End (E2E) Tests:

Not applicable — this is a test-only change with no runtime/user-facing impact.

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.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Adds unit-test coverage for the previously untested _session_util module:

- decode_model: None passthrough, dict-to-model decoding, and invalid input.
- extract_state_delta: routing of app:/user: prefixed keys (with prefix
  stripped), skipping of temp: keys, unprefixed keys to the session bucket,
  empty/None state, and a mixed-key case.
@adk-bot adk-bot added the services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

services [Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants