MCPcopy Create free account
hub / github.com/ScrapeGraphAI/Scrapegraph-ai / test_set_common_params

Function test_set_common_params

tests/graphs/abstract_graph_test.py:51–75  ·  view source on GitHub ↗

Test that the set_common_params method correctly updates the configuration of all nodes in the graph.

()

Source from the content-addressed store, hash-verified

49
50
51def test_set_common_params():
52 """
53 Test that the set_common_params method correctly updates the configuration
54 of all nodes in the graph.
55 """
56 # Create a mock graph with mock nodes
57 mock_graph = Mock()
58 mock_node1 = Mock()
59 mock_node2 = Mock()
60 mock_graph.nodes = [mock_node1, mock_node2]
61 # Create a TestGraph instance with the mock graph
62 with patch.object(TestGraph, "_create_graph", return_value=mock_graph):
63 graph = TestGraph(
64 "Test prompt",
65 {"llm": {"model": "openai/gpt-3.5-turbo", "openai_api_key": "sk-test"}},
66 )
67 # Reset mock call counts before testing set_common_params
68 mock_node1.update_config.reset_mock()
69 mock_node2.update_config.reset_mock()
70 # Call set_common_params with test parameters
71 test_params = {"param1": "value1", "param2": "value2"}
72 graph.set_common_params(test_params)
73 # Assert that update_config was called on each node with the correct parameters
74 mock_node1.update_config.assert_called_once_with(test_params, False)
75 mock_node2.update_config.assert_called_once_with(test_params, False)
76
77
78class TestGraph(AbstractGraph):

Callers

nothing calls this directly

Calls 2

TestGraphClass · 0.85
set_common_paramsMethod · 0.80

Tested by

no test coverage detected