|
| 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 | + """Ensure get_user_choice sets skip_summarization to True.""" |
| 28 | + tool_context = mock.MagicMock() |
| 29 | + |
| 30 | + get_user_choice(["a", "b"], tool_context) |
| 31 | + |
| 32 | + assert tool_context.actions.skip_summarization is True |
| 33 | + |
| 34 | + def test_returns_none(self): |
| 35 | + """Ensure get_user_choice returns None.""" |
| 36 | + tool_context = mock.MagicMock() |
| 37 | + |
| 38 | + assert get_user_choice(["a", "b"], tool_context) is None |
| 39 | + |
| 40 | + |
| 41 | +class TestGetUserChoiceTool: |
| 42 | + |
| 43 | + def test_is_long_running_function_tool(self): |
| 44 | + """Ensure get_user_choice_tool is a LongRunningFunctionTool.""" |
| 45 | + assert isinstance(get_user_choice_tool, LongRunningFunctionTool) |
| 46 | + assert get_user_choice_tool.is_long_running is True |
| 47 | + |
| 48 | + def test_wraps_get_user_choice_function(self): |
| 49 | + """Ensure get_user_choice_tool wraps the get_user_choice function.""" |
| 50 | + assert get_user_choice_tool.func is get_user_choice |
| 51 | + assert get_user_choice_tool.name == "get_user_choice" |
0 commit comments