Skip to content

Commit 464b8b0

Browse files
committed
test: Add smart_scraper_multi_parse_merge_first_graph test
1 parent cdb3c11 commit 464b8b0

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
"""
2+
Module for testing the smart scraper class
3+
"""
4+
5+
import os
6+
import pytest
7+
import pandas as pd
8+
from dotenv import load_dotenv
9+
from scrapegraphai.graphs import SmartScraperMultiParseConcatFirstGraph
10+
from scrapegraphai.utils import prettify_exec_info
11+
12+
load_dotenv()
13+
14+
@pytest.fixture
15+
def graph_config():
16+
"""Configuration of the graph"""
17+
openai_key = os.getenv("OPENAI_APIKEY")
18+
19+
return {
20+
"llm": {
21+
"api_key": openai_key,
22+
"model": "openai/gpt-3.5-turbo",
23+
},
24+
"verbose": True,
25+
"headless": False,
26+
}
27+
28+
def test_scraping_pipeline(graph_config):
29+
"""Start of the scraping pipeline"""
30+
smart_scraper_multi_parse_concat_first_graph = SmartScraperMultiParseConcatFirstGraph(
31+
prompt="Who is Marco Perini?",
32+
source= [
33+
"https://perinim.github.io/",
34+
"https://perinim.github.io/cv/"
35+
],
36+
config=graph_config,
37+
)
38+
39+
result = smart_scraper_multi_parse_concat_first_graph.run()
40+
41+
assert result is not None
42+
assert isinstance(result, dict)
43+
44+
def test_get_execution_info(graph_config):
45+
"""Get the execution info"""
46+
smart_scraper_multi_parse_concat_first_graph = SmartScraperMultiParseConcatFirstGraph(
47+
prompt="Who is Marco Perini?",
48+
source= [
49+
"https://perinim.github.io/",
50+
"https://perinim.github.io/cv/"
51+
],
52+
config=graph_config,
53+
)
54+
55+
smart_scraper_multi_parse_concat_first_graph.run()
56+
57+
graph_exec_info = smart_scraper_multi_parse_concat_first_graph.get_execution_info()
58+
59+
assert graph_exec_info is not None

0 commit comments

Comments
 (0)