|
6 | 6 | import warnings |
7 | 7 | from pathlib import Path |
8 | 8 | from typing import Any, Callable, cast |
9 | | -from unittest.mock import ANY, call, patch |
| 9 | +from unittest.mock import patch |
10 | 10 |
|
11 | 11 | import httpx |
12 | 12 | import pytest |
@@ -3684,17 +3684,16 @@ async def echo_tool(text: str) -> str: |
3684 | 3684 | }, |
3685 | 3685 | ] |
3686 | 3686 |
|
3687 | | - expected_calls = [ |
3688 | | - # First call is the initial input |
3689 | | - call([expected_items[0]], wrapper=ANY), |
3690 | | - # Second call is the first tool call and its result |
3691 | | - call([expected_items[1], expected_items[2]], wrapper=ANY), |
3692 | | - # Third call is the second tool call and its result |
3693 | | - call([expected_items[3], expected_items[4]], wrapper=ANY), |
3694 | | - # Fourth call is the final output |
3695 | | - call([expected_items[5]], wrapper=ANY), |
| 3687 | + expected_item_batches = [ |
| 3688 | + [expected_items[0]], |
| 3689 | + [expected_items[1], expected_items[2]], |
| 3690 | + [expected_items[3], expected_items[4]], |
| 3691 | + [expected_items[5]], |
3696 | 3692 | ] |
3697 | | - assert mock_add_items.call_args_list == expected_calls |
| 3693 | + assert len(mock_add_items.call_args_list) == len(expected_item_batches) |
| 3694 | + paired_calls = zip(mock_add_items.call_args_list, expected_item_batches) |
| 3695 | + for actual_call, expected_batch in paired_calls: |
| 3696 | + assert actual_call.args == (expected_batch,) |
3698 | 3697 | assert result.final_output == "Summary: Echoed foo and bar" |
3699 | 3698 | assert (await session.get_items()) == expected_items |
3700 | 3699 |
|
|
0 commit comments