Skip to content

Python scraper based on AI

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

codebeaver-ai[bot]80dd766ac23d
diff --git a/tests/test_search_graph.py b/tests/test_search_graph.py
index 0b8209c0..099385da 100644
--- a/tests/test_search_graph.py
+++ b/tests/test_search_graph.py
@@ -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
\ No newline at end of file
+ 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
\ No newline at end of file