Tests that inserting and appending nodes works as expected: appending adds to the end, inserting places at the given index.
(ok_small)
| 114 | |
| 115 | |
| 116 | def 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 | |
| 140 | def test_route_iter_returns_all_clients(ok_small): |
nothing calls this directly
no test coverage detected