Skip to content

Commit 4945d35

Browse files
committed
get rid of shipment id
1 parent 21e772a commit 4945d35

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

domain_model.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Shipment(dict):
2-
def __init__(self, id, eta, lines):
3-
self.id = id
2+
def __init__(self, eta, lines):
43
self.eta = eta
54
super().__init__(lines)
65

test_allocation.py

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_can_allocate_to_stock():
2424

2525
def test_can_allocate_to_shipment():
2626
order = {'a-sku': 10}
27-
shipment = Shipment(id='shipment-id', eta=date.today(), lines={
27+
shipment = Shipment(eta=date.today(), lines={
2828
'a-sku': 1000
2929
})
3030

@@ -37,7 +37,7 @@ def test_can_allocate_to_shipment():
3737
def test_ignores_irrelevant_stock():
3838
order = {'sku1': 10}
3939
stock = {'sku2': 1000}
40-
shipment = Shipment(id='shipment-id', eta=date.today(), lines={
40+
shipment = Shipment(eta=date.today(), lines={
4141
'sku1': 1000,
4242
})
4343

@@ -50,10 +50,10 @@ def test_ignores_irrelevant_stock():
5050

5151
def test_can_allocate_to_correct_shipment():
5252
order = {'sku2': 10}
53-
shipment1 = Shipment('shipment1', eta=date.today(), lines={
53+
shipment1 = Shipment(eta=date.today(), lines={
5454
'sku1': 1000,
5555
})
56-
shipment2 = Shipment('shipment2', eta=date.today(), lines={
56+
shipment2 = Shipment(eta=date.today(), lines={
5757
'sku2': 1000,
5858
})
5959

@@ -67,7 +67,7 @@ def test_can_allocate_to_correct_shipment():
6767
def test_allocates_to_stock_in_preference_to_shipment():
6868
order = {'sku1': 10}
6969
stock = {'sku1': 1000}
70-
shipment = Shipment('shipment1', eta=date.today(), lines={
70+
shipment = Shipment(eta=date.today(), lines={
7171
'sku1': 1000,
7272
})
7373

@@ -91,7 +91,7 @@ def test_can_allocate_multiple_lines_to_wh():
9191

9292
def test_can_allocate_multiple_lines_to_shipment():
9393
order = {'sku1': 5, 'sku2': 10}
94-
shipment = Shipment('shipment1', eta=date.today(), lines={
94+
shipment = Shipment(eta=date.today(), lines={
9595
'sku1': 1000,
9696
'sku2': 1000,
9797
})
@@ -106,7 +106,7 @@ def test_can_allocate_multiple_lines_to_shipment():
106106

107107
def test_can_allocate_to_both():
108108
order = {'sku1': 5, 'sku2': 10}
109-
shipment = Shipment('shipment1', eta=date.today(), lines={
109+
shipment = Shipment(eta=date.today(), lines={
110110
'sku2': 1000,
111111
})
112112
stock = {'sku1': 1000}
@@ -121,7 +121,7 @@ def test_can_allocate_to_both():
121121

122122
def test_can_allocate_to_both_preferring_stock():
123123
order = {'sku1': 1, 'sku2': 2, 'sku3': 3, 'sku4': 4}
124-
shipment = Shipment('shipment1', eta=date.today(), lines={
124+
shipment = Shipment(eta=date.today(), lines={
125125
'sku1': 1000,
126126
'sku2': 1000,
127127
'sku3': 1000,
@@ -143,7 +143,7 @@ def test_can_allocate_to_both_preferring_stock():
143143

144144
def test_mixed_allocations_are_avoided_if_possible():
145145
order = {'sku1': 10, 'sku2': 10}
146-
shipment = Shipment('shipment1', eta=date.today(), lines={
146+
shipment = Shipment(eta=date.today(), lines={
147147
'sku1': 1000,
148148
'sku2': 1000,
149149
})
@@ -157,12 +157,12 @@ def test_mixed_allocations_are_avoided_if_possible():
157157

158158
def test_prefer_allocating_to_earlier_shipment():
159159
order = {'sku1': 10, 'sku2': 10}
160-
shipment1 = Shipment('shipment1', eta=date.today(), lines={
160+
shipment1 = Shipment(eta=date.today(), lines={
161161
'sku1': 1000,
162162
'sku2': 1000,
163163
})
164164
tomorrow = date.today() + timedelta(days=1)
165-
shipment2 = Shipment('shipment2', eta=tomorrow, lines={
165+
shipment2 = Shipment(eta=tomorrow, lines={
166166
'sku1': 1000,
167167
'sku2': 1000,
168168
})
@@ -176,16 +176,16 @@ def test_prefer_allocating_to_earlier_shipment():
176176

177177
def test_prefer_allocating_to_earlier_even_if_multiple_shipments():
178178
order = {'sku1': 10, 'sku2': 10, 'sku3': 10}
179-
shipment1 = Shipment(id='shipment1', eta=date.today(), lines={
179+
shipment1 = Shipment(eta=date.today(), lines={
180180
'sku1': 1000,
181181
})
182182
tomorrow = date.today() + timedelta(days=1)
183-
shipment2 = Shipment(id='shipment2', eta=tomorrow, lines={
183+
shipment2 = Shipment(eta=tomorrow, lines={
184184
'sku2': 1000,
185185
'sku3': 1000,
186186
})
187187
later = tomorrow + timedelta(days=1)
188-
shipment3 = Shipment(id='shipment3', eta=later, lines={
188+
shipment3 = Shipment(eta=later, lines={
189189
'sku2': 1000,
190190
'sku3': 1000,
191191
})
@@ -209,7 +209,7 @@ def test_cannot_allocate_if_insufficent_quantity_in_stock():
209209

210210
def test_cannot_allocate_if_insufficent_quantity_in_shipment():
211211
order = {'a-sku': 10}
212-
shipment = Shipment(id='shipment-id', eta=date.today(), lines={
212+
shipment = Shipment(eta=date.today(), lines={
213213
'a-sku': 5,
214214
})
215215

0 commit comments

Comments
 (0)