def test_search_with_default_max_price(mock_valyu):
    """Test search method when max_price is None (uses default)."""
    # Mock the Valyu client and response
    mock_client = Mock()
    mock_valyu.return_value = mock_client

    # Create mock result object
    mock_result = Mock()
    mock_result.content = "Test content"
    mock_result.title = "Test title"
    mock_result.url = "https://test.com"
    mock_result.source = "test_source"
    mock_result.price = 1.0
    mock_result.length = 100
    mock_result.data_type = "text"
    mock_result.relevance_score = 0.8

    # Mock response object
    mock_response = Mock()
    mock_response.results = [mock_result]
    mock_client.search.return_value = mock_response

    tool = ValyuToolSpec(api_key="test_key", max_price=75.0)

    # Test search with max_price=None (should use default)
    documents = tool.search(query="test query", max_price=None)

    # Verify the client was called with the default max_price
    mock_client.search.assert_called_once_with(
        query="test query",
        search_type="all",
        max_num_results=5,
        relevance_threshold=0.5,
        max_price=75.0,  # Should use the default from init
        start_date=None,
        end_date=None,
    )

    # Verify document creation
    assert len(documents) == 1
    assert isinstance(documents[0], Document)
    assert documents[0].text == "Test content"
    assert documents[0].metadata["title"] == "Test title"
    assert documents[0].metadata["url"] == "https://test.com"
    assert documents[0].metadata["source"] == "test_source"
    assert documents[0].metadata["price"] == 1.0
    assert documents[0].metadata["length"] == 100
    assert documents[0].metadata["data_type"] == "text"
    assert documents[0].metadata["relevance_score"] == 0.8
Test search method when max_price is None (uses default).
llama-index-integrations/tools/llama-index-tools-valyu/tests/test_tools_valyu.py