MCPcopy
hub / github.com/openai/openai-agents-python / assert_step_items

Function assert_step_items

tests/test_hitl_session_scenario.py:339–358  ·  view source on GitHub ↗
(
    items: list[dict[str, Any]],
    step: ScenarioStep,
    approval_item: Any,
)

Source from the content-addressed store, hash-verified

337
338
339def 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
361def extract_user_message(input: str | list[TResponseInputItem]) -> str:

Calls 4

extract_user_textFunction · 0.85
extract_output_textFunction · 0.85
extract_call_idFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected