-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a function that displays grouping of shipments by allowed vehic…
…le indices.
- Loading branch information
Showing
3 changed files
with
157 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import unittest | ||
|
||
from google3.third_party.cfr.python.cfr.analysis import analysis | ||
from google3.third_party.cfr.python.cfr.json import cfr_json | ||
|
||
|
||
class VehicleShipmentGroupsTest(unittest.TestCase): | ||
|
||
def test_without_allowed_vehicle_indices(self): | ||
model: cfr_json.ShipmentModel = { | ||
"shipments": [ | ||
{"label": "S001"}, | ||
{"label": "S002"}, | ||
{"label": "S003"}, | ||
{"label": "S004"}, | ||
{"label": "S005"}, | ||
], | ||
"vehicles": [ | ||
{"label": "V001"}, | ||
{"label": "V002"}, | ||
], | ||
} | ||
self.assertSequenceEqual( | ||
analysis.get_vehicle_shipment_groups(model), | ||
(({0, 1}, {0, 1, 2, 3, 4}),), | ||
) | ||
|
||
def test_with_some_allowed_vehicle_indices(self): | ||
model: cfr_json.ShipmentModel = { | ||
"shipments": [ | ||
{"label": "S001", "allowedVehicleIndices": [0, 2]}, | ||
{"label": "S002", "allowedVehicleIndices": [0, 2]}, | ||
{"label": "S003", "allowedVehicleIndices": [1]}, | ||
{"label": "S004", "allowedVehicleIndices": [1, 2, 3]}, | ||
{"label": "S005"}, | ||
], | ||
"vehicles": [ | ||
{"label": "V001"}, | ||
{"label": "V002"}, | ||
{"label": "V003"}, | ||
{"label": "V004"}, | ||
], | ||
} | ||
self.assertCountEqual( | ||
analysis.get_vehicle_shipment_groups(model), | ||
(({0, 2}, {0, 1}), ({1}, {2}), ({1, 2, 3}, {3}), ({0, 1, 2, 3}, {4})), | ||
) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters