def test_agent_not_found_error(self):
    """Test that appropriate error is raised when agent is not found."""
    with tempfile.TemporaryDirectory() as temp_dir:
      loader = AgentLoader(temp_dir)
      agents_dir = temp_dir  # For use in the expected message string

      # Try to load non-existent agent
      with pytest.raises(ValueError) as exc_info:
        loader.load_agent("nonexistent_agent")

      expected_msg_part_1 = "No root_agent found for 'nonexistent_agent'."
      expected_msg_part_2 = (
          "Searched in 'nonexistent_agent.agent.root_agent',"
          " 'nonexistent_agent.root_agent'."
      )
      expected_msg_part_3 = (
          f"Ensure '{agents_dir}/nonexistent_agent' is structured correctly"
      )

      assert expected_msg_part_1 in str(exc_info.value)
      assert expected_msg_part_2 in str(exc_info.value)
      assert expected_msg_part_3 in str(exc_info.value)
Test that appropriate error is raised when agent is not found.
tests/unittests/cli/utils/test_agent_loader.py