MCPcopy Create free account
hub / github.com/PyVRP/PyVRP / test_route_insert

Function test_route_insert

tests/search/test_Route.py:116–137  ·  view source on GitHub ↗

Tests that inserting and appending nodes works as expected: appending adds to the end, inserting places at the given index.

(ok_small)

Source from the content-addressed store, hash-verified

114
115
116def test_route_insert(ok_small):
117 """
118 Tests that inserting and appending nodes works as expected: appending adds
119 to the end, inserting places at the given index.
120 """
121 route = Route(ok_small, idx=0, vehicle_type=0)
122 assert_equal(route.num_clients(), 0)
123 assert_equal(route.num_depots(), 2)
124
125 # Insert a few nodes so we have an actual route.
126 route.append(Node(loc=1))
127 route.append(Node(loc=2))
128 assert_equal(route.num_clients(), 2)
129 assert_equal(route[1].client, 1)
130 assert_equal(route[2].client, 2)
131
132 # # Now insert a new nodes at index 1.
133 route.insert(1, Node(loc=3))
134 assert_equal(route.num_clients(), 3)
135 assert_equal(route[1].client, 3)
136 assert_equal(route[2].client, 1)
137 assert_equal(route[3].client, 2)
138
139
140def test_route_iter_returns_all_clients(ok_small):

Callers

nothing calls this directly

Calls 6

insertMethod · 0.95
NodeClass · 0.85
num_clientsMethod · 0.80
num_depotsMethod · 0.80
appendMethod · 0.80
RouteClass · 0.50

Tested by

no test coverage detected