Files
wehub-resource-sync fbfefa28d3
CodeQL / Analyze (python) (push) Failing after 0s
Release / Build (push) Failing after 1s
Test Suite / Unit Tests (push) Failing after 0s
Release / Release (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:18:10 +08:00

56 lines
1.6 KiB
Python

import unittest
from langchain_ollama import ChatOllama
from scrapegraphai.nodes import SearchInternetNode
class TestSearchInternetNode(unittest.TestCase):
def setUp(self):
# Configuration for the graph
self.graph_config = {
"llm": {"model": "llama3", "temperature": 0, "streaming": True},
"search_engine": "google",
"max_results": 3,
"verbose": True,
}
# Define the model
self.llm_model = ChatOllama(self.graph_config["llm"])
# Initialize the SearchInternetNode
self.search_node = SearchInternetNode(
input="user_input",
output=["search_results"],
node_config={
"llm_model": self.llm_model,
"search_engine": self.graph_config["search_engine"],
"max_results": self.graph_config["max_results"],
"verbose": self.graph_config["verbose"],
},
)
def test_execute_search_node(self):
# Initial state
state = {"user_input": "What is the capital of France?"}
# Expected output
expected_output = {
"user_input": "What is the capital of France?",
"search_results": [
"https://en.wikipedia.org/wiki/Paris",
"https://en.wikipedia.org/wiki/France",
"https://en.wikipedia.org/wiki/%C3%8Ele-de-France",
],
}
# Execute the node
result = self.search_node.execute(state)
# Assert the results
self.assertEqual(result, expected_output)
if __name__ == "__main__":
unittest.main()