def test_convert_handles_missing_content_or_parts():
  """Test that events missing content or parts are skipped gracefully."""
  events = [
      build_event("user", [{"text": "Query 1"}]),
      Event(author="agent", content=None),  # Agent event missing content
      build_event("agent", [{"text": "Response 1"}]),
      Event(author="user", content=None),  # User event missing content
      build_event("user", [{"text": "Query 2"}]),
      Event(
          author="agent", content=types.Content(parts=[])
      ),  # Agent event with empty parts list
      build_event("agent", [{"text": "Response 2"}]),
      # User event with content but no parts (or None parts)
      Event(author="user", content=types.Content(parts=None)),
      build_event("user", [{"text": "Query 3"}]),
      build_event("agent", [{"text": "Response 3"}]),
  ]
  session = Session(id="s1", app_name="app", user_id="u1", events=events)
  expected = [
      {  # Turn 1 (from Query 1)
          "query": "Query 1",
          "expected_tool_use": [],
          "expected_intermediate_agent_responses": [],
          "reference": "Response 1",
      },
      {  # Turn 2 (from Query 2 - user event with None content was skipped)
          "query": "Query 2",
          "expected_tool_use": [],
          "expected_intermediate_agent_responses": [],
          "reference": "Response 2",
      },
      {  # Turn 3 (from Query 3 - user event with None parts was skipped)
          "query": "Query 3",
          "expected_tool_use": [],
          "expected_intermediate_agent_responses": [],
          "reference": "Response 3",
      },
  ]
  assert convert_session_to_eval_format(session) == expected
Test that events missing content or parts are skipped gracefully.
tests/unittests/cli/utils/test_evals.py