Skip to content

Commit 2781c3c

Browse files
authored
Merge pull request #355 from tejhande/patch-3
Test ScriptCreatorGraph and print execution info
2 parents 14d1011 + ff9df81 commit 2781c3c

File tree

1 file changed

+35
-37
lines changed

1 file changed

+35
-37
lines changed

tests/graphs/script_generator_test.py

Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,45 @@
1-
"""
1+
"""
22
Module for making the tests for ScriptGeneratorGraph
33
"""
44
import pytest
55
from scrapegraphai.graphs import ScriptCreatorGraph
66
from scrapegraphai.utils import prettify_exec_info
77

8-
98
@pytest.fixture
109
def graph_config():
11-
"""
12-
Configuration of the graph
13-
"""
14-
return {
15-
"llm": {
16-
"model": "ollama/mistral",
17-
"temperature": 0,
18-
"format": "json",
19-
"base_url": "http://localhost:11434",
20-
"library": "beautifoulsoup",
21-
},
22-
"embeddings": {
23-
"model": "ollama/nomic-embed-text",
24-
"temperature": 0,
25-
"base_url": "http://localhost:11434",
26-
},
27-
"library": "beautifoulsoup"
28-
}
29-
10+
"""
11+
Configuration of the graph
12+
"""
13+
return {
14+
"llm": {
15+
"model": "ollama/mistral",
16+
"temperature": 0,
17+
"format": "json",
18+
"base_url": "http://localhost:11434",
19+
"library": "beautifulsoup",
20+
},
21+
"embeddings": {
22+
"model": "ollama/nomic-embed-text",
23+
"temperature": 0,
24+
"base_url": "http://localhost:11434",
25+
},
26+
"library": "beautifulsoup"
27+
}
3028

3129
def test_script_creator_graph(graph_config: dict):
32-
"""
33-
Start of the scraping pipeline
34-
"""
35-
smart_scraper_graph = ScriptCreatorGraph(
36-
prompt="List me all the news with their description.",
37-
source="https://perinim.github.io/projects",
38-
config=graph_config
39-
)
40-
41-
result = smart_scraper_graph.run()
42-
43-
assert result is not None
44-
45-
graph_exec_info = smart_scraper_graph.get_execution_info()
46-
47-
assert graph_exec_info is not None
30+
"""
31+
Test the ScriptCreatorGraph
32+
"""
33+
smart_scraper_graph = ScriptCreatorGraph(
34+
prompt="List me all the news with their description.",
35+
source="https://perinim.github.io/projects",
36+
config=graph_config
37+
)
38+
result = smart_scraper_graph.run()
39+
assert result is not None, "ScriptCreatorGraph execution failed to produce a result."
40+
graph_exec_info = smart_scraper_graph.get_execution_info()
41+
assert graph_exec_info is not None, "ScriptCreatorGraph execution info is None."
42+
prettified_exec_info = prettify_exec_info(graph_exec_info)
43+
print(prettified_exec_info)
44+
45+
# Perform additional assertions on the result or execution info as needed

0 commit comments

Comments
 (0)