refactor: separate initialization of nodes and edges in test_graph.py (#2828)
* refactor: move test_graph.py * refactor: allow Graph to be initialized with no nodes and edges The Graph class in `base.py` was refactored to separate the initialization of nodes and edges into a separate method called `add_nodes_and_edges()`. This improves code readability and maintainability by organizing the code logic more effectively. * refactor: separate initialization of nodes and edges in get_graph() The `get_graph()` function in `conftest.py` was refactored to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively. * refactor: separate initialization of nodes and edges in test_graph.py * refactor: separate initialization of nodes and edges in base.py The `add_node()` and `add_edge()` methods were added to the `Graph` class in `base.py` to separate the initialization of nodes and edges. This improves code readability and maintainability by organizing the code logic more effectively.
This commit is contained in:
parent
077f68f17b
commit
77cc789e62
3 changed files with 51 additions and 33 deletions
|
|
@ -158,7 +158,9 @@ def get_graph(_type="basic"):
|
|||
data_graph = flow_graph["data"]
|
||||
nodes = data_graph["nodes"]
|
||||
edges = data_graph["edges"]
|
||||
return Graph(nodes, edges)
|
||||
graph = Graph()
|
||||
graph.add_nodes_and_edges(nodes, edges)
|
||||
return graph
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@ def test_invalid_node_types():
|
|||
"edges": [],
|
||||
}
|
||||
with pytest.raises(Exception):
|
||||
Graph(graph_data["nodes"], graph_data["edges"])
|
||||
g = Graph()
|
||||
g.add_nodes_and_edges(graph_data["nodes"], graph_data["edges"])
|
||||
|
||||
|
||||
def test_get_vertices_with_target(basic_graph):
|
||||
Loading…
Add table
Add a link
Reference in a new issue