def test_search_multiple_results(mock_valyu):
    """Test search method with multiple results."""
    # Mock the Valyu client and response
    mock_client = Mock()
    mock_valyu.return_value = mock_client

    # Create multiple mock result objects
    mock_result1 = Mock()
    mock_result1.content = "First result content"
    mock_result1.title = "First title"
    mock_result1.url = "https://first.com"
    mock_result1.source = "first_source"
    mock_result1.price = 1.0
    mock_result1.length = 100
    mock_result1.data_type = "text"
    mock_result1.relevance_score = 0.9

    mock_result2 = Mock()
    mock_result2.content = "Second result content"
    mock_result2.title = "Second title"
    mock_result2.url = "https://second.com"
    mock_result2.source = "second_source"
    mock_result2.price = 2.0
    mock_result2.length = 200
    mock_result2.data_type = "text"
    mock_result2.relevance_score = 0.8

    # Mock response object
    mock_response = Mock()
    mock_response.results = [mock_result1, mock_result2]
    mock_client.search.return_value = mock_response

    tool = ValyuToolSpec(api_key="test_key")

    # Test search with multiple results
    documents = tool.search(query="multi result query")

    # Verify multiple documents were created
    assert len(documents) == 2
    assert documents[0].text == "First result content"
    assert documents[1].text == "Second result content"
    assert documents[0].metadata["title"] == "First title"
    assert documents[1].metadata["title"] == "Second title"
Test search method with multiple results.
llama-index-integrations/tools/llama-index-tools-valyu/tests/test_tools_valyu.py