(
items: list[dict[str, Any]],
step: ScenarioStep,
approval_item: Any,
)
| 337 | |
| 338 | |
| 339 | def assert_step_items( |
| 340 | items: list[dict[str, Any]], |
| 341 | step: ScenarioStep, |
| 342 | approval_item: Any, |
| 343 | ) -> None: |
| 344 | user_items = [item for item in items if item.get("role") == "user"] |
| 345 | function_calls = [item for item in items if item.get("type") == "function_call"] |
| 346 | function_outputs = [item for item in items if item.get("type") == "function_call_output"] |
| 347 | |
| 348 | assert len(user_items) == 1 |
| 349 | assert len(function_calls) == 1 |
| 350 | assert len(function_outputs) == 1 |
| 351 | |
| 352 | assert extract_user_text(user_items[0]) == step.message |
| 353 | assert function_calls[0].get("name") == step.tool_name |
| 354 | |
| 355 | approval_call_id = extract_call_id(approval_item.raw_item) |
| 356 | assert function_calls[0].get("call_id") == approval_call_id |
| 357 | assert function_outputs[0].get("call_id") == approval_call_id |
| 358 | assert extract_output_text(function_outputs[0]) == step.expected_output |
| 359 | |
| 360 | |
| 361 | def extract_user_message(input: str | list[TResponseInputItem]) -> str: |
no test coverage detected