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

Function test_raises_wrong_mutual_group_referencing

tests/test_ProblemData.py:886–917  ·  view source on GitHub ↗

Groups should reference the clients in the group, and vice versa, the client should reference the group. If this is not done correctly, a ValueError should be thrown.

()

Source from the content-addressed store, hash-verified

884
885
886def test_raises_wrong_mutual_group_referencing():
887 """
888 Groups should reference the clients in the group, and vice versa, the
889 client should reference the group. If this is not done correctly, a
890 ValueError should be thrown.
891 """
892 with assert_raises(ValueError):
893 ProblemData(
894 # The client references the first group, which does not contain the
895 # client. That should raise.
896 clients=[
897 Client(1, 1, required=False, group=0),
898 Client(2, 2, required=False, group=0),
899 ],
900 depots=[Depot(1, 1)],
901 vehicle_types=[VehicleType()],
902 distance_matrices=[np.zeros((3, 3))],
903 duration_matrices=[np.zeros((3, 3))],
904 groups=[ClientGroup([2])],
905 )
906
907 with assert_raises(ValueError):
908 ProblemData(
909 clients=[Client(1, 1), Client(2, 2)],
910 depots=[Depot(1, 1)],
911 vehicle_types=[VehicleType()],
912 distance_matrices=[np.zeros((3, 3))],
913 duration_matrices=[np.zeros((3, 3))],
914 # Group references a client that is not in the group. That should
915 # raise as well.
916 groups=[ClientGroup([1])],
917 )
918
919
920def test_raises_for_required_mutually_exclusive_group_membership():

Callers

nothing calls this directly

Calls 5

ProblemDataClass · 0.90
ClientClass · 0.90
DepotClass · 0.90
VehicleTypeClass · 0.90
ClientGroupClass · 0.90

Tested by

no test coverage detected