mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-07-09 21:19:20 +08:00
test: Update coverage improvement test for tests/test_search_graph.py
This commit is contained in:
parent
9919e7c122
commit
16c688f090
@ -33,4 +33,28 @@ class TestSearchGraph:
|
||||
search_graph.run()
|
||||
|
||||
# Assert
|
||||
assert search_graph.get_considered_urls() == urls
|
||||
assert search_graph.get_considered_urls() == urls
|
||||
|
||||
@patch('scrapegraphai.graphs.search_graph.BaseGraph')
|
||||
@patch('scrapegraphai.graphs.abstract_graph.AbstractGraph._create_llm')
|
||||
def test_run_no_answer_found(self, mock_create_llm, mock_base_graph):
|
||||
"""
|
||||
Test that the run() method returns "No answer found." when the final state
|
||||
doesn't contain an "answer" key.
|
||||
"""
|
||||
# Arrange
|
||||
prompt = "Test prompt"
|
||||
config = {"llm": {"model": "test-model"}}
|
||||
|
||||
# Mock the _create_llm method to return a MagicMock
|
||||
mock_create_llm.return_value = MagicMock()
|
||||
|
||||
# Mock the execute method to set the final_state without an "answer" key
|
||||
mock_base_graph.return_value.execute.return_value = ({"urls": []}, {})
|
||||
|
||||
# Act
|
||||
search_graph = SearchGraph(prompt, config)
|
||||
result = search_graph.run()
|
||||
|
||||
# Assert
|
||||
assert result == "No answer found."
|
||||
Loading…
Reference in New Issue
Block a user