Skip to content

Commit a918336

Browse files
committed
Add test
Signed-off-by: Thijs Baaijen <13253091+Thijss@users.noreply.github.com>
1 parent b7f8afb commit a918336

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/unit/model/graphs/test_graph_model.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
"""Grid tests"""
66

7+
from collections import Counter
8+
79
import numpy as np
810
import pytest
911
from numpy.testing import assert_array_equal
@@ -338,3 +340,26 @@ def test_get_connected_ignore_multiple_nodes(self, graph_with_2_routes):
338340
connected_nodes = graph.get_connected(node_id=1, nodes_to_ignore=[2, 4])
339341

340342
assert {5} == set(connected_nodes)
343+
344+
345+
def test_tmp_remove_nodes(graph_with_2_routes) -> None:
346+
graph = graph_with_2_routes
347+
348+
assert graph.nr_branches == 4
349+
350+
# add parallel branches to test whether they are restored correctly
351+
graph.add_branch(1, 5)
352+
graph.add_branch(5, 1)
353+
354+
assert graph.nr_nodes == 5
355+
assert graph.nr_branches == 6
356+
counter_before: Counter[frozenset] = Counter(graph.all_branches)
357+
358+
with graph.tmp_remove_nodes([1, 2]):
359+
assert graph.nr_nodes == 3
360+
assert graph.all_branches == [{4, 5}]
361+
362+
assert graph.nr_nodes == 5
363+
assert graph.nr_branches == 6
364+
counter_after: Counter[frozenset] = Counter(graph.all_branches)
365+
assert counter_before == counter_after

0 commit comments

Comments
 (0)