fix: update broken test imports to match current API

- Replace removed ScrapeGraph with SmartScraperGraph in scrape_graph_test.py
- Replace renamed convert_to_csv/convert_to_json with export_to_csv/export_to_json in xml_scraper_openai_test.py
This commit is contained in:
khadyottakale 2026-03-04 13:38:00 +05:30
parent 54d147309d
commit 536e5adcde
2 changed files with 13 additions and 12 deletions

View File

@ -1,5 +1,5 @@
"""
Module for testing the scrape graph class
Module for testing the smart scraper graph class
"""
import os
@ -7,7 +7,7 @@ import os
import pytest
from dotenv import load_dotenv
from scrapegraphai.graphs import ScrapeGraph
from scrapegraphai.graphs import SmartScraperGraph
load_dotenv()
@ -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,
@ -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

View File

@ -8,7 +8,7 @@ import pytest
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()
@ -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")