def test_parse_routes(self): """Asserts that Routes are correctly parsed from the Opt. solution""" params = get_params() estimator = LinearEstimator() problem_builder = ProblemBuilder(params=params, estimator=estimator) model_builder = OptimizationModelBuilder( constraints=[CapacityConstraint()]) riders = parse_models(model_dicts=test_riders, cls=Rider) vehicles = parse_models(model_dicts=test_vehicles, cls=Vehicle) depots = parse_models(model_dicts=test_depots, cls=Depot) problem = problem_builder.build(riders, vehicles, depots) model = model_builder.build(problem) solution = model.solve() routes = Router._parse_routes(problem, solution) self.assertTrue(routes, msg='Routes could not be built.') for route in routes: self.assertTrue(route['vehicle_id'], msg='Route without vehicle.') self.assertTrue(len(route['stops']) > 1, msg='Route with single stop.')