Skip to content

Commit fe48d87

Browse files
BowedMars2copybara-github
authored andcommitted
test: adds missing unit tests for example_util (Issue #4623)
Merge #4802 **Please ensure you have read the [contribution guide](https://github.com/google/adk-python/blob/main/CONTRIBUTING.md) before creating a pull request.** ### Link to Issue or Description of Change - Closes: #4623 **Problem:** example_util.py was completely missing unit tests. **Solution:** I added unit tests for a variety of situations: - Converting a text-only example to a string - Converting a text-only example _with multiple Parts_ to a string - Converting a text-only example to a string when the output contains a conversation between the user and model - Converting another text-only example with a conversational output, but with clumped messages from each - Converting an empty list to a string - Converting an example including a function call to a string - Converting an example including a function _response_ to a string - Converting an example including both a function call _and_ a function response to a string - Converting an example with text, a function call, and a function response to a string - Building System Information from a list of examples - Building System Information from an example provider ### Testing Plan I ran the tests personally, and they successfully passed. **Unit Tests:** - [✓] I have added or updated unit tests for my change. - [✓] All unit tests pass locally. 33 passed in 2.55s **Manual End-to-End (E2E) Tests:** To test my change, simply run the unit tests and they should pass. If you want to verify the effectiveness of my tests, try modifying the input given to my unit tests and see if they fail. ### Checklist - [✓] I have read the [CONTRIBUTING.md](https://github.com/google/adk-python/blob/main/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. ### Additional context - I noticed build_example_si takes an argument for query even though it's not used if you pass in a list rather than a BaseExampleProvider. Is this expected behavior that is there for a reason, or should I open an issue for this? - I also noticed that when model is None, it defaults to Gemini 2. This seems like it could cause issues on the user end. Is there a reason for this functionality? COPYBARA_INTEGRATE_REVIEW=#4802 from BowedMars374878:Issue-#4623 efa090e PiperOrigin-RevId: 901025765
1 parent 8eb0d74 commit fe48d87

File tree

3 files changed

+471
-1
lines changed

3 files changed

+471
-1
lines changed

src/google/adk/examples/example_util.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
_FUNCTION_RESPONSE_SUFFIX = "\n```\n"
4747

4848

49-
# TODO(yaojie): Add unit tests for this function.
5049
def convert_examples_to_text(
5150
examples: list[Example], model: Optional[str]
5251
) -> str:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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.

0 commit comments

Comments
 (0)