Skip to content

Commit 28934ac

Browse files
committed
stock is just lines too
1 parent e6f7384 commit 28934ac

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

domain_model.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@ class OrderLine(Line):
1212
allocation: str = None
1313

1414

15-
@dataclass
16-
class Stock:
17-
sku: str
18-
quantity: int
19-
20-
2115
@dataclass
2216
class Shipment:
2317
id: str

test_allocation.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
Line,
77
OrderLine,
88
Shipment,
9-
Stock,
109
allocate,
1110
)
1211

@@ -22,9 +21,9 @@ def test_can_allocate_to_warehouse_stock():
2221
order = [
2322
OrderLine(sku=sku, quantity=10),
2423
]
25-
stock = Stock(sku=sku, quantity=1000)
24+
stock = [Line(sku=sku, quantity=1000)]
2625

27-
allocate(order, [stock], shipments=[])
26+
allocate(order, stock, shipments=[])
2827

2928
assert order[0].allocation == 'warehouse'
3029

@@ -48,12 +47,12 @@ def test_ignores_invalid_stock():
4847
order = [
4948
OrderLine(sku=sku1, quantity=10),
5049
]
51-
stock = Stock(sku=sku2, quantity=1000)
50+
stock = [Line(sku=sku2, quantity=1000)]
5251
shipment = Shipment(id=random_id(), eta=date.today(), lines=[
5352
Line(sku=sku1, quantity=1000),
5453
])
5554

56-
allocate(order, stock=[stock], shipments=[shipment])
55+
allocate(order, stock=stock, shipments=[shipment])
5756

5857
assert order[0].allocation == shipment.id
5958

@@ -80,12 +79,12 @@ def test_allocates_to_warehouse_stock_in_preference_to_shipment():
8079
order = [
8180
OrderLine(sku=sku, quantity=10),
8281
]
83-
stock = Stock(sku=sku, quantity=1000)
82+
stock = [Line(sku=sku, quantity=1000)]
8483
shipment = Shipment(id=random_id(), eta=date.today(), lines=[
8584
Line(sku=sku, quantity=1000),
8685
])
8786

88-
allocate(order, [stock], shipments=[shipment])
87+
allocate(order, stock, shipments=[shipment])
8988

9089
assert order[0].allocation == 'warehouse'
9190

@@ -97,8 +96,8 @@ def test_can_allocate_multiple_lines_to_wh():
9796
OrderLine(sku=sku2, quantity=10),
9897
]
9998
stock = [
100-
Stock(sku=sku1, quantity=1000),
101-
Stock(sku=sku2, quantity=1000),
99+
Line(sku=sku1, quantity=1000),
100+
Line(sku=sku2, quantity=1000),
102101
]
103102

104103
allocate(order, stock, shipments=[])
@@ -132,9 +131,7 @@ def test_can_allocate_to_both():
132131
shipment = Shipment(id=random_id(), eta=date.today(), lines=[
133132
Line(sku=sku2, quantity=1000),
134133
])
135-
stock = [
136-
Stock(sku=sku1, quantity=1000),
137-
]
134+
stock = [Line(sku=sku1, quantity=1000)]
138135

139136
allocate(order, stock, shipments=[shipment])
140137

@@ -156,8 +153,8 @@ def test_can_allocate_to_both_preferring_stock():
156153
Line(sku=sku3, quantity=1000),
157154
])
158155
stock = [
159-
Stock(sku=sku3, quantity=1000),
160-
Stock(sku=sku4, quantity=1000),
156+
Line(sku=sku3, quantity=1000),
157+
Line(sku=sku4, quantity=1000),
161158
]
162159

163160
allocate(order, stock, shipments=[shipment])

0 commit comments

Comments
 (0)