33
44
55from domain_model import (
6- Order ,
76 Shipment ,
87 allocate ,
98)
@@ -14,7 +13,7 @@ def random_id():
1413
1514
1615def test_can_allocate_to_stock ():
17- order = Order ( {'a-sku' : 10 })
16+ order = {'a-sku' : 10 }
1817 stock = {'a-sku' : 1000 }
1918
2019 allocations = allocate (order , stock , shipments = [])
@@ -24,7 +23,7 @@ def test_can_allocate_to_stock():
2423
2524
2625def test_can_allocate_to_shipment ():
27- order = Order ( {'a-sku' : 10 })
26+ order = {'a-sku' : 10 }
2827 shipment = Shipment (id = 'shipment-id' , eta = date .today (), lines = {
2928 'a-sku' : 1000
3029 })
@@ -36,7 +35,7 @@ def test_can_allocate_to_shipment():
3635
3736
3837def test_ignores_irrelevant_stock ():
39- order = Order ( {'sku1' : 10 })
38+ order = {'sku1' : 10 }
4039 stock = {'sku2' : 1000 }
4140 shipment = Shipment (id = 'shipment-id' , eta = date .today (), lines = {
4241 'sku1' : 1000 ,
@@ -50,7 +49,7 @@ def test_ignores_irrelevant_stock():
5049
5150
5251def test_can_allocate_to_correct_shipment ():
53- order = Order ( {'sku2' : 10 })
52+ order = {'sku2' : 10 }
5453 shipment1 = Shipment ('shipment1' , eta = date .today (), lines = {
5554 'sku1' : 1000 ,
5655 })
@@ -66,7 +65,7 @@ def test_can_allocate_to_correct_shipment():
6665
6766
6867def test_allocates_to_stock_in_preference_to_shipment ():
69- order = Order ( {'sku1' : 10 })
68+ order = {'sku1' : 10 }
7069 stock = {'sku1' : 1000 }
7170 shipment = Shipment ('shipment1' , eta = date .today (), lines = {
7271 'sku1' : 1000 ,
@@ -80,7 +79,7 @@ def test_allocates_to_stock_in_preference_to_shipment():
8079
8180
8281def test_can_allocate_multiple_lines_to_wh ():
83- order = Order ( {'sku1' : 5 , 'sku2' : 10 })
82+ order = {'sku1' : 5 , 'sku2' : 10 }
8483 stock = {'sku1' : 1000 , 'sku2' : 1000 }
8584
8685 allocations = allocate (order , stock , shipments = [])
@@ -91,7 +90,7 @@ def test_can_allocate_multiple_lines_to_wh():
9190
9291
9392def test_can_allocate_multiple_lines_to_shipment ():
94- order = Order ( {'sku1' : 5 , 'sku2' : 10 })
93+ order = {'sku1' : 5 , 'sku2' : 10 }
9594 shipment = Shipment ('shipment1' , eta = date .today (), lines = {
9695 'sku1' : 1000 ,
9796 'sku2' : 1000 ,
@@ -106,7 +105,7 @@ def test_can_allocate_multiple_lines_to_shipment():
106105
107106
108107def test_can_allocate_to_both ():
109- order = Order ( {'sku1' : 5 , 'sku2' : 10 })
108+ order = {'sku1' : 5 , 'sku2' : 10 }
110109 shipment = Shipment ('shipment1' , eta = date .today (), lines = {
111110 'sku2' : 1000 ,
112111 })
@@ -121,7 +120,7 @@ def test_can_allocate_to_both():
121120
122121
123122def test_can_allocate_to_both_preferring_stock ():
124- order = Order ( {'sku1' : 1 , 'sku2' : 2 , 'sku3' : 3 , 'sku4' : 4 })
123+ order = {'sku1' : 1 , 'sku2' : 2 , 'sku3' : 3 , 'sku4' : 4 }
125124 shipment = Shipment ('shipment1' , eta = date .today (), lines = {
126125 'sku1' : 1000 ,
127126 'sku2' : 1000 ,
@@ -143,7 +142,7 @@ def test_can_allocate_to_both_preferring_stock():
143142
144143
145144def test_mixed_allocations_are_avoided_if_possible ():
146- order = Order ( {'sku1' : 10 , 'sku2' : 10 })
145+ order = {'sku1' : 10 , 'sku2' : 10 }
147146 shipment = Shipment ('shipment1' , eta = date .today (), lines = {
148147 'sku1' : 1000 ,
149148 'sku2' : 1000 ,
@@ -157,7 +156,7 @@ def test_mixed_allocations_are_avoided_if_possible():
157156
158157
159158def test_prefer_allocating_to_earlier_shipment ():
160- order = Order ( {'sku1' : 10 , 'sku2' : 10 })
159+ order = {'sku1' : 10 , 'sku2' : 10 }
161160 shipment1 = Shipment ('shipment1' , eta = date .today (), lines = {
162161 'sku1' : 1000 ,
163162 'sku2' : 1000 ,
@@ -176,7 +175,7 @@ def test_prefer_allocating_to_earlier_shipment():
176175
177176
178177def test_prefer_allocating_to_earlier_even_if_multiple_shipments ():
179- order = Order ( {'sku1' : 10 , 'sku2' : 10 , 'sku3' : 10 })
178+ order = {'sku1' : 10 , 'sku2' : 10 , 'sku3' : 10 }
180179 shipment1 = Shipment (id = 'shipment1' , eta = date .today (), lines = {
181180 'sku1' : 1000 ,
182181 })
@@ -200,7 +199,7 @@ def test_prefer_allocating_to_earlier_even_if_multiple_shipments():
200199
201200
202201def test_cannot_allocate_if_insufficent_quantity_in_stock ():
203- order = Order ( {'a-sku' : 10 })
202+ order = {'a-sku' : 10 }
204203 stock = {'a-sku' : 5 }
205204
206205 allocations = allocate (order , stock , shipments = [])
@@ -209,7 +208,7 @@ def test_cannot_allocate_if_insufficent_quantity_in_stock():
209208
210209
211210def test_cannot_allocate_if_insufficent_quantity_in_shipment ():
212- order = Order ( {'a-sku' : 10 })
211+ order = {'a-sku' : 10 }
213212 shipment = Shipment (id = 'shipment-id' , eta = date .today (), lines = {
214213 'a-sku' : 5 ,
215214 })
@@ -220,8 +219,8 @@ def test_cannot_allocate_if_insufficent_quantity_in_shipment():
220219
221220
222221def test_cannot_allocate_more_orders_than_we_have_stock_for ():
223- order1 = Order ( {'a-sku' : 10 })
224- order2 = Order ( {'a-sku' : 10 })
222+ order1 = {'a-sku' : 10 }
223+ order2 = {'a-sku' : 10 }
225224 stock = {'a-sku' : 15 }
226225
227226 allocations1 = allocate (order1 , stock , shipments = [])
0 commit comments