@@ -67,8 +67,6 @@ def test_can_allocate_to_correct_shipment():
6767 assert allocations [0 ].quantity == 10
6868
6969
70-
71-
7270def test_allocates_to_warehouse_stock_in_preference_to_shipment ():
7371 sku = random_id ()
7472 order = Order (id = random_id (), lines = [
@@ -118,3 +116,23 @@ def test_can_allocate_multiple_lines_to_shipment():
118116 assert Allocation (order .id , sku1 , 10 , shipment_id = shipment .id ) in allocations
119117 assert Allocation (order .id , sku2 , 10 , shipment_id = shipment .id ) in allocations
120118
119+
120+ def test_can_allocate_to_both ():
121+ sku1 , sku2 = random_id (), random_id ()
122+ order = Order (id = random_id (), lines = [
123+ OrderLine (sku = sku1 , quantity = 10 ),
124+ OrderLine (sku = sku2 , quantity = 10 ),
125+ ])
126+ shipment = Shipment (id = random_id (), eta = date .today (), lines = [
127+ OrderLine (sku = sku2 , quantity = 1000 ),
128+ ])
129+ stock = [
130+ Stock (sku = sku1 , quantity = 1000 ),
131+ ]
132+
133+ allocations = allocate (order , stock , shipments = [shipment ])
134+ assert Allocation (order .id , sku1 , 10 , shipment_id = None ) in allocations
135+ assert Allocation (order .id , sku2 , 10 , shipment_id = shipment .id ) in allocations
136+
137+
138+
0 commit comments