Skip to content

Commit c286b16

Browse files
authored
feat: Add tests for SmartScraperGraph using sample text and configuration fixtures (@tejhande)
- Added pytest fixture to provide sample text from a file. - Added pytest fixture to provide graph configuration. - Implemented test_scraping_pipeline to test the execution of SmartScraperGraph. - Added assertions to verify the result is not None and to check the expected structure of the result. Contributed by @tejhande
1 parent 08f1be6 commit c286b16

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

tests/graphs/scrape_plain_text_mistral_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@
55
import pytest
66
from scrapegraphai.graphs import SmartScraperGraph
77

8-
98
@pytest.fixture
109
def sample_text():
1110
"""
12-
Example of text
11+
Example of text fixture.
1312
"""
1413
file_name = "inputs/plain_html_example.txt"
1514
curr_dir = os.path.dirname(os.path.realpath(__file__))
@@ -20,11 +19,10 @@ def sample_text():
2019

2120
return text
2221

23-
2422
@pytest.fixture
2523
def graph_config():
2624
"""
27-
Configuration of the graph
25+
Configuration of the graph fixture.
2826
"""
2927
return {
3028
"llm": {
@@ -40,10 +38,9 @@ def graph_config():
4038
}
4139
}
4240

43-
44-
def test_scraping_pipeline(sample_text: str, graph_config: dict):
41+
def test_scraping_pipeline(sample_text, graph_config):
4542
"""
46-
Start of the scraping pipeline
43+
Test the SmartScraperGraph scraping pipeline.
4744
"""
4845
smart_scraper_graph = SmartScraperGraph(
4946
prompt="List me all the news with their description.",
@@ -54,3 +51,6 @@ def test_scraping_pipeline(sample_text: str, graph_config: dict):
5451
result = smart_scraper_graph.run()
5552

5653
assert result is not None
54+
# Additional assertions to check the structure of the result can be added here
55+
assert isinstance(result, dict) # Assuming the result is a dictionary
56+
assert "news" in result # Assuming the result should contain a key "news"

0 commit comments

Comments
 (0)