@@ -17,9 +17,9 @@ def test_can_allocate_to_stock():
17
17
order = Order ({'a-sku' : 10 })
18
18
stock = {'a-sku' : 1000 }
19
19
20
- allocate (order , stock , shipments = [])
20
+ allocations = allocate (order , stock , shipments = [])
21
21
22
- assert order . allocations ['a-sku' ] == 'STOCK'
22
+ assert allocations ['a-sku' ] == 'STOCK'
23
23
assert stock ['a-sku' ] == 990
24
24
25
25
@@ -29,9 +29,9 @@ def test_can_allocate_to_shipment():
29
29
'a-sku' : 1000
30
30
})
31
31
32
- allocate (order , stock = [], shipments = [shipment ])
32
+ allocations = allocate (order , stock = [], shipments = [shipment ])
33
33
34
- assert order . allocations ['a-sku' ] == shipment .id
34
+ assert allocations ['a-sku' ] == shipment .id
35
35
assert shipment ['a-sku' ] == 990
36
36
37
37
@@ -42,9 +42,9 @@ def test_ignores_irrelevant_stock():
42
42
'sku1' : 1000 ,
43
43
})
44
44
45
- allocate (order , stock = stock , shipments = [shipment ])
45
+ allocations = allocate (order , stock = stock , shipments = [shipment ])
46
46
47
- assert order . allocations ['sku1' ] == shipment .id
47
+ assert allocations ['sku1' ] == shipment .id
48
48
assert stock ['sku2' ] == 1000
49
49
assert shipment ['sku1' ] == 990
50
50
@@ -58,9 +58,9 @@ def test_can_allocate_to_correct_shipment():
58
58
'sku2' : 1000 ,
59
59
})
60
60
61
- allocate (order , stock = [], shipments = [shipment1 , shipment2 ])
61
+ allocations = allocate (order , stock = [], shipments = [shipment1 , shipment2 ])
62
62
63
- assert order . allocations ['sku2' ] == shipment2 .id
63
+ assert allocations ['sku2' ] == shipment2 .id
64
64
assert shipment1 ['sku1' ] == 1000
65
65
assert shipment2 ['sku2' ] == 990
66
66
@@ -72,9 +72,9 @@ def test_allocates_to_stock_in_preference_to_shipment():
72
72
'sku1' : 1000 ,
73
73
})
74
74
75
- allocate (order , stock , shipments = [shipment ])
75
+ allocations = allocate (order , stock , shipments = [shipment ])
76
76
77
- assert order . allocations ['sku1' ] == 'STOCK'
77
+ assert allocations ['sku1' ] == 'STOCK'
78
78
assert stock ['sku1' ] == 990
79
79
assert shipment ['sku1' ] == 1000
80
80
@@ -83,9 +83,9 @@ def test_can_allocate_multiple_lines_to_wh():
83
83
order = Order ({'sku1' : 5 , 'sku2' : 10 })
84
84
stock = {'sku1' : 1000 , 'sku2' : 1000 }
85
85
86
- allocate (order , stock , shipments = [])
87
- assert order . allocations ['sku1' ] == 'STOCK'
88
- assert order . allocations ['sku2' ] == 'STOCK'
86
+ allocations = allocate (order , stock , shipments = [])
87
+ assert allocations ['sku1' ] == 'STOCK'
88
+ assert allocations ['sku2' ] == 'STOCK'
89
89
assert stock ['sku1' ] == 995
90
90
assert stock ['sku2' ] == 990
91
91
@@ -97,10 +97,10 @@ def test_can_allocate_multiple_lines_to_shipment():
97
97
'sku2' : 1000 ,
98
98
})
99
99
100
- allocate (order , [], shipments = [shipment ])
100
+ allocations = allocate (order , [], shipments = [shipment ])
101
101
102
- assert order . allocations ['sku1' ] == shipment .id
103
- assert order . allocations ['sku2' ] == shipment .id
102
+ assert allocations ['sku1' ] == shipment .id
103
+ assert allocations ['sku2' ] == shipment .id
104
104
assert shipment ['sku1' ] == 995
105
105
assert shipment ['sku2' ] == 990
106
106
@@ -112,10 +112,10 @@ def test_can_allocate_to_both():
112
112
})
113
113
stock = {'sku1' : 1000 }
114
114
115
- allocate (order , stock , shipments = [shipment ])
115
+ allocations = allocate (order , stock , shipments = [shipment ])
116
116
117
- assert order . allocations ['sku1' ] == 'STOCK'
118
- assert order . allocations ['sku2' ] == shipment .id
117
+ assert allocations ['sku1' ] == 'STOCK'
118
+ assert allocations ['sku2' ] == shipment .id
119
119
assert stock ['sku1' ] == 995
120
120
assert shipment ['sku2' ] == 990
121
121
@@ -129,12 +129,12 @@ def test_can_allocate_to_both_preferring_stock():
129
129
})
130
130
stock = {'sku3' : 1000 , 'sku4' : 1000 }
131
131
132
- allocate (order , stock , shipments = [shipment ])
132
+ allocations = allocate (order , stock , shipments = [shipment ])
133
133
134
- assert order . allocations ['sku1' ] == shipment .id
135
- assert order . allocations ['sku2' ] == shipment .id
136
- assert order . allocations ['sku3' ] == 'STOCK'
137
- assert order . allocations ['sku4' ] == 'STOCK'
134
+ assert allocations ['sku1' ] == shipment .id
135
+ assert allocations ['sku2' ] == shipment .id
136
+ assert allocations ['sku3' ] == 'STOCK'
137
+ assert allocations ['sku4' ] == 'STOCK'
138
138
assert shipment ['sku1' ] == 999
139
139
assert shipment ['sku2' ] == 998
140
140
assert shipment ['sku3' ] == 1000
@@ -150,10 +150,10 @@ def test_mixed_allocations_are_avoided_if_possible():
150
150
})
151
151
stock = {'sku1' : 1000 }
152
152
153
- allocate (order , stock , shipments = [shipment ])
153
+ allocations = allocate (order , stock , shipments = [shipment ])
154
154
155
- assert order . allocations ['sku1' ] == shipment .id
156
- assert order . allocations ['sku2' ] == shipment .id
155
+ assert allocations ['sku1' ] == shipment .id
156
+ assert allocations ['sku2' ] == shipment .id
157
157
158
158
159
159
def test_prefer_allocating_to_earlier_shipment ():
@@ -169,10 +169,10 @@ def test_prefer_allocating_to_earlier_shipment():
169
169
})
170
170
stock = {}
171
171
172
- allocate (order , stock , shipments = [shipment2 , shipment1 ])
172
+ allocations = allocate (order , stock , shipments = [shipment2 , shipment1 ])
173
173
174
- assert order . allocations ['sku1' ] == shipment1 .id
175
- assert order . allocations ['sku2' ] == shipment1 .id
174
+ assert allocations ['sku1' ] == shipment1 .id
175
+ assert allocations ['sku2' ] == shipment1 .id
176
176
177
177
178
178
def test_prefer_allocating_to_earlier_even_if_multiple_shipments ():
@@ -192,20 +192,20 @@ def test_prefer_allocating_to_earlier_even_if_multiple_shipments():
192
192
})
193
193
stock = {}
194
194
195
- allocate (order , stock , shipments = [shipment3 , shipment2 , shipment1 ])
195
+ allocations = allocate (order , stock , shipments = [shipment3 , shipment2 , shipment1 ])
196
196
197
- assert order . allocations ['sku1' ] == shipment1 .id
198
- assert order . allocations ['sku2' ] == shipment2 .id
199
- assert order . allocations ['sku3' ] == shipment2 .id
197
+ assert allocations ['sku1' ] == shipment1 .id
198
+ assert allocations ['sku2' ] == shipment2 .id
199
+ assert allocations ['sku3' ] == shipment2 .id
200
200
201
201
202
202
def test_cannot_allocate_if_insufficent_quantity_in_stock ():
203
203
order = Order ({'a-sku' : 10 })
204
204
stock = {'a-sku' : 5 }
205
205
206
- allocate (order , stock , shipments = [])
206
+ allocations = allocate (order , stock , shipments = [])
207
207
208
- assert 'a-sku' not in order . allocations
208
+ assert 'a-sku' not in allocations
209
209
210
210
211
211
def test_cannot_allocate_if_insufficent_quantity_in_shipment ():
@@ -214,18 +214,19 @@ def test_cannot_allocate_if_insufficent_quantity_in_shipment():
214
214
'a-sku' : 5 ,
215
215
})
216
216
217
- allocate (order , stock = [], shipments = [shipment ])
217
+ allocations = allocate (order , stock = [], shipments = [shipment ])
218
218
219
- assert 'a-sku' not in order . allocations
219
+ assert 'a-sku' not in allocations
220
220
221
221
222
222
def test_cannot_allocate_more_orders_than_we_have_stock_for ():
223
223
order1 = Order ({'a-sku' : 10 })
224
224
order2 = Order ({'a-sku' : 10 })
225
225
stock = {'a-sku' : 15 }
226
226
227
- allocate (order1 , stock , shipments = [])
228
- allocate (order2 , stock , shipments = [])
227
+ allocations1 = allocate (order1 , stock , shipments = [])
228
+ allocations2 = allocate (order2 , stock , shipments = [])
229
229
230
- assert 'a-sku' not in order2 .allocations
230
+ assert 'a-sku' in allocations1
231
+ assert 'a-sku' not in allocations2
231
232
0 commit comments