Skip to content

Commit cdb3c11

Browse files
committed
test: Add scrape_graph test
1 parent 3e3e1b2 commit cdb3c11

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

tests/graphs/scrape_graph_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
"""
2+
Module for testing the scrape graph 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 ScrapeGraph
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+
return {
19+
"llm": {
20+
"api_key": openai_key,
21+
"model": "openai/gpt-3.5-turbo",
22+
},
23+
"verbose": True,
24+
"headless": False,
25+
}
26+
27+
def test_scraping_pipeline(graph_config):
28+
"""Start of the scraping pipeline"""
29+
scrape_graph = ScrapeGraph(
30+
source="https://perinim.github.io/projects/",
31+
config=graph_config,
32+
)
33+
34+
result = scrape_graph.run()
35+
36+
assert result is not None
37+
assert isinstance(result, list)
38+
39+
def test_get_execution_info(graph_config):
40+
"""Get the execution info"""
41+
scrape_graph = ScrapeGraph(
42+
source="https://perinim.github.io/projects/",
43+
config=graph_config,
44+
)
45+
46+
scrape_graph.run()
47+
48+
graph_exec_info = scrape_graph.get_execution_info()
49+
50+
assert graph_exec_info is not None

0 commit comments

Comments
 (0)