Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions tests/graphs/scrape_graph_test.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Module for testing the scrape graph class
Module for testing the smart scraper graph class
"""

import os

import pytest
from dotenv import load_dotenv

from scrapegraphai.graphs import ScrapeGraph
from scrapegraphai.graphs import SmartScraperGraph

load_dotenv()

Expand All @@ -19,7 +19,7 @@ def graph_config():
return {
"llm": {
"api_key": openai_key,
"model": "openai/gpt-3.5-turbo",
"model": "openai/gpt-4o",
},
"verbose": True,
"headless": False,
Expand All @@ -28,26 +28,27 @@ def graph_config():

def test_scraping_pipeline(graph_config):
"""Start of the scraping pipeline"""
scrape_graph = ScrapeGraph(
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the projects with their descriptions",
source="https://perinim.github.io/projects/",
config=graph_config,
)

result = scrape_graph.run()
result = smart_scraper_graph.run()

assert result is not None
assert isinstance(result, list)


def test_get_execution_info(graph_config):
"""Get the execution info"""
scrape_graph = ScrapeGraph(
smart_scraper_graph = SmartScraperGraph(
prompt="List me all the projects with their descriptions",
source="https://perinim.github.io/projects/",
config=graph_config,
)

scrape_graph.run()
smart_scraper_graph.run()

graph_exec_info = scrape_graph.get_execution_info()
graph_exec_info = smart_scraper_graph.get_execution_info()

assert graph_exec_info is not None
6 changes: 3 additions & 3 deletions tests/graphs/xml_scraper_openai_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from dotenv import load_dotenv

from scrapegraphai.graphs import XMLScraperGraph
from scrapegraphai.utils import convert_to_csv, convert_to_json, prettify_exec_info
from scrapegraphai.utils import export_to_csv, export_to_json, prettify_exec_info

load_dotenv()

Expand Down Expand Up @@ -96,8 +96,8 @@ def test_xml_scraper_save_results(graph_config: dict, xml_content: str):
result = xml_scraper_graph.run()

# Save to csv and json
convert_to_csv(result, "result")
convert_to_json(result, "result")
export_to_csv(result, "result")
export_to_json(result, "result")

assert os.path.exists("result.csv")
assert os.path.exists("result.json")