Skip to content

Commit 19bc13e

Browse files
committed
look at me, got rid of another class
1 parent a2e6e28 commit 19bc13e

2 files changed

Lines changed: 16 additions & 23 deletions

File tree

domain_model.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
class Order(dict):
2-
def __init__(self, lines):
3-
self.allocations = {}
4-
super().__init__(lines)
5-
6-
71
class Shipment(dict):
82
def __init__(self, id, eta, lines):
93
self.id = id

test_allocation.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44

55
from domain_model import (
6-
Order,
76
Shipment,
87
allocate,
98
)
@@ -14,7 +13,7 @@ def random_id():
1413

1514

1615
def 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

2625
def 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

3837
def 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

5251
def 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

6867
def 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

8281
def 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

9392
def 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

108107
def 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

123122
def 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

145144
def 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

159158
def 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

178177
def 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

202201
def 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

211210
def 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

222221
def 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

Comments
 (0)