@@ -26,6 +26,57 @@ def test_from_arrays(basic_grid):
2626 assert set (basic_grid .node .id ) == set (graphs .complete_graph .external_ids )
2727
2828
29+ @pytest .fixture
30+ def graph_container_with_5_nodes ():
31+ graph_container = GraphContainer .empty ()
32+ for node_id in range (1 , 6 ):
33+ node = NodeArray .empty (1 )
34+ node .id = node_id
35+ graph_container .add_node (node )
36+ return graph_container
37+
38+
39+ @pytest .fixture
40+ def three_winding_transformers ():
41+ three_winding_transformers = ThreeWindingTransformerArray .empty (2 )
42+ three_winding_transformers .id = [301 , 302 ]
43+ three_winding_transformers .node_1 = [1 , 1 ]
44+ three_winding_transformers .node_2 = [2 , 4 ]
45+ three_winding_transformers .node_3 = [3 , 5 ]
46+ three_winding_transformers .status_1 = [1 , 1 ]
47+ three_winding_transformers .status_2 = [1 , 1 ]
48+ three_winding_transformers .status_3 = [0 , 1 ]
49+
50+ return three_winding_transformers
51+
52+
53+ def test_add_branch3 (graph_container_with_5_nodes , three_winding_transformers ):
54+ graph_container_with_5_nodes .add_branch3 (three_winding_transformers )
55+ for from_node , to_node in [(1 , 2 ), (1 , 4 ), (1 , 5 ), (4 , 5 )]:
56+ assert graph_container_with_5_nodes .active_graph .has_branch (from_node , to_node )
57+ assert graph_container_with_5_nodes .complete_graph .has_branch (from_node , to_node )
58+
59+ for from_node , to_node in [(1 , 3 ), (2 , 3 )]:
60+ assert not graph_container_with_5_nodes .active_graph .has_branch (from_node , to_node )
61+ assert graph_container_with_5_nodes .complete_graph .has_branch (from_node , to_node )
62+
63+
64+ def test_delete_branch3 (graph_container_with_5_nodes , three_winding_transformers ):
65+ graph_container_with_5_nodes .add_branch3 (three_winding_transformers )
66+ graph_container_with_5_nodes .delete_branch3 (three_winding_transformers [0 ])
67+
68+ assert not graph_container_with_5_nodes .active_graph .has_branch (1 , 2 )
69+ assert not graph_container_with_5_nodes .complete_graph .has_branch (1 , 2 )
70+ for from_node , to_node in [(1 , 4 ), (1 , 5 ), (4 , 5 )]:
71+ assert graph_container_with_5_nodes .active_graph .has_branch (from_node , to_node )
72+ assert graph_container_with_5_nodes .complete_graph .has_branch (from_node , to_node )
73+ graph_container_with_5_nodes .delete_branch3 (three_winding_transformers [1 ])
74+
75+ for from_node , to_node in [(1 , 2 ), (1 , 4 ), (1 , 5 ), (4 , 5 )]:
76+ assert not graph_container_with_5_nodes .active_graph .has_branch (from_node , to_node )
77+ assert not graph_container_with_5_nodes .complete_graph .has_branch (from_node , to_node )
78+
79+
2980def test_from_arrays_active_three_winding (basic_grid ):
3081 nodes = NodeArray .zeros (3 )
3182 nodes .id = [1000 , 1001 , 1002 ]
0 commit comments