Skip to content

Commit 22fdf19

Browse files
test(tools): add unit tests for get_user_choice_tool
Adds unit-test coverage for the previously untested get_user_choice_tool module: that get_user_choice sets skip_summarization and returns None, and that get_user_choice_tool is a LongRunningFunctionTool wrapping that function.
1 parent 816a87f commit 22fdf19

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Copyright 2026 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
from __future__ import annotations
16+
17+
from unittest import mock
18+
19+
from google.adk.tools.get_user_choice_tool import get_user_choice
20+
from google.adk.tools.get_user_choice_tool import get_user_choice_tool
21+
from google.adk.tools.long_running_tool import LongRunningFunctionTool
22+
23+
24+
class TestGetUserChoice:
25+
26+
def test_sets_skip_summarization(self):
27+
tool_context = mock.MagicMock()
28+
29+
get_user_choice(["a", "b"], tool_context)
30+
31+
assert tool_context.actions.skip_summarization is True
32+
33+
def test_returns_none(self):
34+
tool_context = mock.MagicMock()
35+
36+
assert get_user_choice(["a", "b"], tool_context) is None
37+
38+
39+
class TestGetUserChoiceTool:
40+
41+
def test_is_long_running_function_tool(self):
42+
assert isinstance(get_user_choice_tool, LongRunningFunctionTool)
43+
assert get_user_choice_tool.is_long_running is True
44+
45+
def test_wraps_get_user_choice_function(self):
46+
assert get_user_choice_tool.func is get_user_choice
47+
assert get_user_choice_tool.name == "get_user_choice"

0 commit comments

Comments
 (0)