11from domain_model import allocate
22
33
4- def test_can_allocate_to_stock ():
4+ def test_can_allocate_to_warehouse ():
55 order = {'a-sku' : 10 }
6- stock = {'a-sku' : 1000 }
6+ warehouse = {'a-sku' : 1000 }
77
8- allocations = allocate (order , stock , shipments = [])
8+ allocations = allocate (order , warehouse , shipments = [])
99
10- assert allocations ['a-sku' ] == stock
10+ assert allocations ['a-sku' ] == warehouse
1111
1212
1313def test_can_allocate_to_shipment ():
1414 order = {'a-sku' : 10 }
1515 shipment = {'a-sku' : 1000 }
1616
17- allocations = allocate (order , stock = {}, shipments = [shipment ])
17+ allocations = allocate (order , warehouse = {}, shipments = [shipment ])
1818
1919 assert allocations ['a-sku' ] == shipment
2020
2121
22- def test_ignores_irrelevant_stock ():
22+ def test_ignores_irrelevant_warehouse_stock ():
2323 order = {'sku1' : 10 }
24- stock = {'sku2' : 1000 }
24+ warehouse = {'sku2' : 1000 }
2525 shipment = {'sku1' : 1000 }
2626
27- allocations = allocate (order , stock = stock , shipments = [shipment ])
27+ allocations = allocate (order , warehouse = warehouse , shipments = [shipment ])
2828
2929 assert allocations ['sku1' ] == shipment
3030
@@ -34,35 +34,35 @@ def test_can_allocate_to_correct_shipment():
3434 shipment1 = {'sku1' : 1000 }
3535 shipment2 = {'sku2' : 1000 }
3636
37- allocations = allocate (order , stock = {}, shipments = [shipment1 , shipment2 ])
37+ allocations = allocate (order , warehouse = {}, shipments = [shipment1 , shipment2 ])
3838
3939 assert allocations ['sku2' ] == shipment2
4040
4141
42- def test_allocates_to_stock_in_preference_to_shipment ():
42+ def test_allocates_to_warehouse_in_preference_to_shipment ():
4343 order = {'sku1' : 10 }
44- stock = {'sku1' : 1000 }
44+ warehouse = {'sku1' : 1000 }
4545 shipment = {'sku1' : 1000 }
4646
47- allocations = allocate (order , stock , shipments = [shipment ])
47+ allocations = allocate (order , warehouse , shipments = [shipment ])
4848
49- assert allocations ['sku1' ] == stock
49+ assert allocations ['sku1' ] == warehouse
5050
5151
52- def test_can_allocate_multiple_lines_to_wh ():
52+ def test_can_allocate_multiple_lines_to_warehouse ():
5353 order = {'sku1' : 5 , 'sku2' : 10 }
54- stock = {'sku1' : 1000 , 'sku2' : 1000 }
54+ warehouse = {'sku1' : 1000 , 'sku2' : 1000 }
5555
56- allocations = allocate (order , stock , shipments = [])
57- assert allocations ['sku1' ] == stock
58- assert allocations ['sku2' ] == stock
56+ allocations = allocate (order , warehouse , shipments = [])
57+ assert allocations ['sku1' ] == warehouse
58+ assert allocations ['sku2' ] == warehouse
5959
6060
6161def test_can_allocate_multiple_lines_to_shipment ():
6262 order = {'sku1' : 5 , 'sku2' : 10 }
6363 shipment = {'sku1' : 1000 , 'sku2' : 1000 }
6464
65- allocations = allocate (order , stock = {}, shipments = [shipment ])
65+ allocations = allocate (order , warehouse = {}, shipments = [shipment ])
6666
6767 assert allocations ['sku1' ] == shipment
6868 assert allocations ['sku2' ] == shipment
@@ -71,34 +71,34 @@ def test_can_allocate_multiple_lines_to_shipment():
7171def test_can_allocate_to_both ():
7272 order = {'sku1' : 5 , 'sku2' : 10 }
7373 shipment = {'sku2' : 1000 }
74- stock = {'sku1' : 1000 }
74+ warehouse = {'sku1' : 1000 }
7575
76- allocations = allocate (order , stock , shipments = [shipment ])
76+ allocations = allocate (order , warehouse , shipments = [shipment ])
7777
78- assert allocations ['sku1' ] == stock
78+ assert allocations ['sku1' ] == warehouse
7979 assert allocations ['sku2' ] == shipment
8080
8181
82- def test_can_allocate_to_both_preferring_stock ():
82+ def test_can_allocate_to_both_preferring_warehouse ():
8383 order = {'sku1' : 1 , 'sku2' : 2 , 'sku3' : 3 , 'sku4' : 4 }
8484 shipment = {'sku1' : 1000 , 'sku2' : 1000 , 'sku3' : 1000 }
85- stock = {'sku3' : 1000 , 'sku4' : 1000 }
85+ warehouse = {'sku3' : 1000 , 'sku4' : 1000 }
8686
87- allocations = allocate (order , stock , shipments = [shipment ])
87+ allocations = allocate (order , warehouse , shipments = [shipment ])
8888
8989 assert allocations ['sku1' ] == shipment
9090 assert allocations ['sku2' ] == shipment
91- assert allocations ['sku3' ] == stock
92- assert allocations ['sku4' ] == stock
91+ assert allocations ['sku3' ] == warehouse
92+ assert allocations ['sku4' ] == warehouse
9393
9494
9595def test_allocated_to_first_suitable_shipment_in_list ():
9696 order = {'sku1' : 10 , 'sku2' : 10 }
9797 shipment1 = {'sku1' : 1000 , 'sku2' : 1000 }
9898 shipment2 = {'sku1' : 1000 , 'sku2' : 1000 }
99- stock = {}
99+ warehouse = {}
100100
101- allocations = allocate (order , stock , shipments = [shipment1 , shipment2 ])
101+ allocations = allocate (order , warehouse , shipments = [shipment1 , shipment2 ])
102102
103103 assert allocations ['sku1' ] == shipment1
104104 assert allocations ['sku2' ] == shipment1
@@ -109,34 +109,34 @@ def test_still_preserves_ordering_if_split_across_shipments():
109109 shipment1 = {'sku1' : 1000 }
110110 shipment2 = {'sku2' : 1000 , 'sku3' : 1000 }
111111 shipment3 = {'sku2' : 1000 , 'sku3' : 1000 }
112- stock = {}
112+ warehouse = {}
113113
114- allocations = allocate (order , stock , shipments = [shipment1 , shipment2 , shipment3 ])
114+ allocations = allocate (order , warehouse , shipments = [shipment1 , shipment2 , shipment3 ])
115115
116116 assert allocations ['sku1' ] == shipment1
117117 assert allocations ['sku2' ] == shipment2
118118 assert allocations ['sku3' ] == shipment2
119119
120120
121- def test_stock_not_quite_enough_means_we_use_shipment ():
121+ def test_warehouse_not_quite_enough_means_we_use_shipment ():
122122 order = {'sku1' : 10 , 'sku2' : 10 }
123- stock = {'sku1' : 10 , 'sku2' : 5 }
123+ warehouse = {'sku1' : 10 , 'sku2' : 5 }
124124 shipment = {
125125 'sku1' : 1000 ,
126126 'sku2' : 1000 ,
127127 }
128128
129- allocations = allocate (order , stock , shipments = [shipment ])
129+ allocations = allocate (order , warehouse , shipments = [shipment ])
130130
131131 assert allocations ['sku1' ] == shipment
132132 assert allocations ['sku2' ] == shipment
133133
134134
135- def test_cannot_allocate_if_insufficent_quantity_in_stock ():
135+ def test_cannot_allocate_if_insufficent_quantity_in_warehouse ():
136136 order = {'a-sku' : 10 }
137- stock = {'a-sku' : 5 }
137+ warehouse = {'a-sku' : 5 }
138138
139- allocations = allocate (order , stock , shipments = [])
139+ allocations = allocate (order , warehouse , shipments = [])
140140
141141 assert 'a-sku' not in allocations
142142
@@ -147,7 +147,7 @@ def test_cannot_allocate_if_insufficent_quantity_in_shipment():
147147 'a-sku' : 5 ,
148148 }
149149
150- allocations = allocate (order , stock = {}, shipments = [shipment ])
150+ allocations = allocate (order , warehouse = {}, shipments = [shipment ])
151151
152152 assert 'a-sku' not in allocations
153153
0 commit comments