test: Update coverage improvement test for tests/test_search_graph.py

This commit is contained in:
codebeaver-ai[bot] 2025-01-29 10:25:52 +00:00 committed by GitHub
parent c9d71af1ef
commit 80dd766ac2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -79,4 +79,29 @@ class TestSearchGraph:
# Assert
mock_search_internet.assert_called_once()
call_args = mock_search_internet.call_args
assert call_args.kwargs['node_config']['max_results'] == max_results
assert call_args.kwargs['node_config']['max_results'] == max_results
@patch('scrapegraphai.graphs.search_graph.SearchInternetNode')
@patch('scrapegraphai.graphs.search_graph.GraphIteratorNode')
@patch('scrapegraphai.graphs.search_graph.MergeAnswersNode')
@patch('scrapegraphai.graphs.search_graph.BaseGraph')
@patch('scrapegraphai.graphs.abstract_graph.AbstractGraph._create_llm')
def test_custom_search_engine_config(self, mock_create_llm, mock_base_graph, mock_merge_answers, mock_graph_iterator, mock_search_internet):
"""
Test that the custom search_engine parameter from the config is correctly passed to the SearchInternetNode.
"""
# Arrange
prompt = "Test prompt"
custom_search_engine = "custom_engine"
config = {
"llm": {"model": "test-model"},
"search_engine": custom_search_engine
}
# Act
search_graph = SearchGraph(prompt, config)
# Assert
mock_search_internet.assert_called_once()
call_args = mock_search_internet.call_args
assert call_args.kwargs['node_config']['search_engine'] == custom_search_engine