Scrapegraph-ai/tests/nodes/robot_node_test.py
2024-05-11 12:23:50 +02:00

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