Skip to content

Commit 80dd766

Browse files
test: Update coverage improvement test for tests/test_search_graph.py
1 parent c9d71af commit 80dd766

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/test_search_graph.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,29 @@ def test_max_results_config(self, mock_create_llm, mock_base_graph, mock_merge_a
7979
# Assert
8080
mock_search_internet.assert_called_once()
8181
call_args = mock_search_internet.call_args
82-
assert call_args.kwargs['node_config']['max_results'] == max_results
82+
assert call_args.kwargs['node_config']['max_results'] == max_results
83+
84+
@patch('scrapegraphai.graphs.search_graph.SearchInternetNode')
85+
@patch('scrapegraphai.graphs.search_graph.GraphIteratorNode')
86+
@patch('scrapegraphai.graphs.search_graph.MergeAnswersNode')
87+
@patch('scrapegraphai.graphs.search_graph.BaseGraph')
88+
@patch('scrapegraphai.graphs.abstract_graph.AbstractGraph._create_llm')
89+
def test_custom_search_engine_config(self, mock_create_llm, mock_base_graph, mock_merge_answers, mock_graph_iterator, mock_search_internet):
90+
"""
91+
Test that the custom search_engine parameter from the config is correctly passed to the SearchInternetNode.
92+
"""
93+
# Arrange
94+
prompt = "Test prompt"
95+
custom_search_engine = "custom_engine"
96+
config = {
97+
"llm": {"model": "test-model"},
98+
"search_engine": custom_search_engine
99+
}
100+
101+
# Act
102+
search_graph = SearchGraph(prompt, config)
103+
104+
# Assert
105+
mock_search_internet.assert_called_once()
106+
call_args = mock_search_internet.call_args
107+
assert call_args.kwargs['node_config']['search_engine'] == custom_search_engine

0 commit comments

Comments
 (0)