mirror of
https://github.com/VinciGit00/Scrapegraph-ai.git
synced 2026-06-23 21:00:30 +08:00
58 lines
1.2 KiB
Python
58 lines
1.2 KiB
Python
"""
|
|
Module for testinh robot_node
|
|
"""
|
|
import pytest
|
|
from scrapegraphai.models import Ollama
|
|
from scrapegraphai.nodes import RobotsNode
|
|
|
|
|
|
@pytest.fixture
|
|
def setup():
|
|
"""
|
|
setup
|
|
"""
|
|
# ************************************************
|
|
# Define the configuration for the graph
|
|
# ************************************************
|
|
|
|
graph_config = {
|
|
"llm": {
|
|
"model": "ollama/llama3",
|
|
"temperature": 0,
|
|
"streaming": True
|
|
},
|
|
}
|
|
|
|
# ************************************************
|
|
# Define the node
|
|
# ************************************************
|
|
|
|
llm_model = Ollama(graph_config["llm"])
|
|
|
|
robots_node = RobotsNode(
|
|
input="url",
|
|
output=["is_scrapable"],
|
|
node_config={"llm": llm_model,
|
|
"headless": False
|
|
}
|
|
)
|
|
|
|
return robots_node
|
|
|
|
# ************************************************
|
|
# Test the node
|
|
# ************************************************
|
|
|
|
|
|
def test_robots_node(setup):
|
|
"""
|
|
Run the tests
|
|
"""
|
|
state = {
|
|
"url": "https://twitter.com/home"
|
|
}
|
|
|
|
result = setup.execute(state)
|
|
|
|
assert result is not None
|