Commit fe48d87
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: 9010257651 parent 8eb0d74 commit fe48d87
File tree
3 files changed
+471
-1
lines changed- src/google/adk/examples
- tests/unittests/examples
3 files changed
+471
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | 49 | | |
51 | 50 | | |
52 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
0 commit comments