Skip to content

Commit ff9df81

Browse files
authored
Test ScriptCreatorGraph and print execution info
This commit enhances the test suite for the ScriptCreatorGraph class by improving code readability, adding more informative assertions, and printing the prettified execution information. Changes: - Added more descriptive docstrings for better code documentation. - Improved assertion messages to provide better debugging experience in case of failures. - Added a line to print the prettified execution information using the `prettify_exec_info` function. - Included a comment to remind developers to add additional assertions on the result or execution info if needed. - Fixed a minor typo in the configuration dictionary (`beautifulsoup` instead of `beautifoulsoup`). Benefits: - Improved code readability and maintainability with better documentation. - Enhanced debugging experience with more informative assertion messages. - Easier analysis of the ScriptCreatorGraph execution by printing the prettified execution information. - Reminder to add more assertions for comprehensive testing of the ScriptCreatorGraph. - Corrected a minor typo to ensure consistency. The test suite now provides a more user-friendly experience for developers working on the ScriptCreatorGraph class. The printed execution information will aid in debugging and understanding the graph's execution flow, while the improved assertions and documentation will make the test suite more robust and maintainable.
1 parent 261c4fc commit ff9df81

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)