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.
()
| 884 | |
| 885 | |
| 886 | def 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 | |
| 920 | def test_raises_for_required_mutually_exclusive_group_membership(): |
nothing calls this directly
no test coverage detected