Skip to content

Commit f4c9883

Browse files
committed
s/allocations/allocation/ for consistency
1 parent d1af5d1 commit f4c9883

2 files changed

Lines changed: 33 additions & 33 deletions

File tree

‎domain_model.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,30 @@ def skus(self):
1111
@dataclass
1212
class Order:
1313
lines: dict
14-
allocations: dict = None
14+
allocation: Allocation = None
1515

1616
@property
1717
def skus(self):
1818
return self.lines.keys()
1919

2020
@property
2121
def fully_allocated(self):
22-
return self.allocations.skus == self.skus
22+
return self.allocation.skus == self.skus
2323

2424

2525
def allocate(self, stock, shipments):
26-
self.allocations = {}
26+
self.allocation = {}
2727
for source in [stock] + shipments:
2828
allocation = Allocation({
2929
sku: source
3030
for sku, quantity in self.lines.items()
3131
if source.can_allocate(sku, quantity)
3232
})
3333
if allocation.skus == self.skus:
34-
self.allocations = allocation
34+
self.allocation = allocation
3535
return
36-
allocation.update(self.allocations)
37-
self.allocations = allocation
36+
allocation.update(self.allocation)
37+
self.allocation = allocation
3838

3939

4040
@dataclass

‎test_allocation.py‎

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

88
order.allocate(stock, shipments=[])
99

10-
assert order.allocations['a-sku'] == stock
10+
assert order.allocation['a-sku'] == stock
1111

1212

1313
def test_can_allocate_to_shipment():
@@ -16,7 +16,7 @@ def test_can_allocate_to_shipment():
1616

1717
order.allocate(stock=Stock({}), shipments=[shipment])
1818

19-
assert order.allocations['a-sku'] == shipment
19+
assert order.allocation['a-sku'] == shipment
2020

2121

2222
def test_ignores_irrelevant_stock():
@@ -26,7 +26,7 @@ def test_ignores_irrelevant_stock():
2626

2727
order.allocate(stock=stock, shipments=[shipment])
2828

29-
assert order.allocations['sku1'] == shipment
29+
assert order.allocation['sku1'] == shipment
3030

3131

3232

@@ -37,7 +37,7 @@ def test_can_allocate_to_correct_shipment():
3737

3838
order.allocate(stock=Stock({}), shipments=[shipment1, shipment2])
3939

40-
assert order.allocations['sku2'] == shipment2
40+
assert order.allocation['sku2'] == shipment2
4141

4242

4343
def test_allocates_to_stock_in_preference_to_shipment():
@@ -47,16 +47,16 @@ def test_allocates_to_stock_in_preference_to_shipment():
4747

4848
order.allocate(stock, shipments=[shipment])
4949

50-
assert order.allocations['sku1'] == stock
50+
assert order.allocation['sku1'] == stock
5151

5252

5353
def test_can_allocate_multiple_lines_to_wh():
5454
order = Order({'sku1': 5, 'sku2': 10})
5555
stock = Stock({'sku1': 1000, 'sku2': 1000})
5656

5757
order.allocate(stock, shipments=[])
58-
assert order.allocations['sku1'] == stock
59-
assert order.allocations['sku2'] == stock
58+
assert order.allocation['sku1'] == stock
59+
assert order.allocation['sku2'] == stock
6060

6161

6262
def test_can_allocate_multiple_lines_to_shipment():
@@ -65,8 +65,8 @@ def test_can_allocate_multiple_lines_to_shipment():
6565

6666
order.allocate(stock=Stock({}), shipments=[shipment])
6767

68-
assert order.allocations['sku1'] == shipment
69-
assert order.allocations['sku2'] == shipment
68+
assert order.allocation['sku1'] == shipment
69+
assert order.allocation['sku2'] == shipment
7070

7171

7272
def test_can_allocate_to_both():
@@ -76,8 +76,8 @@ def test_can_allocate_to_both():
7676

7777
order.allocate(stock, shipments=[shipment])
7878

79-
assert order.allocations['sku1'] == stock
80-
assert order.allocations['sku2'] == shipment
79+
assert order.allocation['sku1'] == stock
80+
assert order.allocation['sku2'] == shipment
8181

8282

8383
def test_can_allocate_to_both_preferring_stock():
@@ -87,22 +87,22 @@ def test_can_allocate_to_both_preferring_stock():
8787

8888
order.allocate(stock, shipments=[shipment])
8989

90-
assert order.allocations['sku1'] == shipment
91-
assert order.allocations['sku2'] == shipment
92-
assert order.allocations['sku3'] == stock
93-
assert order.allocations['sku4'] == stock
90+
assert order.allocation['sku1'] == shipment
91+
assert order.allocation['sku2'] == shipment
92+
assert order.allocation['sku3'] == stock
93+
assert order.allocation['sku4'] == stock
9494

9595

9696

97-
def test_mixed_allocations_are_avoided_if_possible():
97+
def test_mixed_allocation_are_avoided_if_possible():
9898
order = Order({'sku1': 10, 'sku2': 10})
9999
shipment = Stock({'sku1': 1000, 'sku2': 1000})
100100
stock = Stock({'sku1': 1000})
101101

102102
order.allocate(stock, shipments=[shipment])
103103

104-
assert order.allocations['sku1'] == shipment
105-
assert order.allocations['sku2'] == shipment
104+
assert order.allocation['sku1'] == shipment
105+
assert order.allocation['sku2'] == shipment
106106

107107

108108
def test_allocated_to_first_suitable_shipment_in_list():
@@ -113,8 +113,8 @@ def test_allocated_to_first_suitable_shipment_in_list():
113113

114114
order.allocate(stock, shipments=[shipment1, shipment2])
115115

116-
assert order.allocations['sku1'] == shipment1
117-
assert order.allocations['sku2'] == shipment1
116+
assert order.allocation['sku1'] == shipment1
117+
assert order.allocation['sku2'] == shipment1
118118

119119

120120
def test_still_preserves_ordering_if_split_across_shipments():
@@ -126,9 +126,9 @@ def test_still_preserves_ordering_if_split_across_shipments():
126126

127127
order.allocate(stock, shipments=[shipment1, shipment2, shipment3])
128128

129-
assert order.allocations['sku1'] == shipment1
130-
assert order.allocations['sku2'] == shipment2
131-
assert order.allocations['sku3'] == shipment2
129+
assert order.allocation['sku1'] == shipment1
130+
assert order.allocation['sku2'] == shipment2
131+
assert order.allocation['sku3'] == shipment2
132132

133133

134134
def test_stock_not_quite_enough_means_we_use_shipment():
@@ -141,8 +141,8 @@ def test_stock_not_quite_enough_means_we_use_shipment():
141141

142142
order.allocate(stock, shipments=[shipment])
143143

144-
assert order.allocations['sku1'] == shipment
145-
assert order.allocations['sku2'] == shipment
144+
assert order.allocation['sku1'] == shipment
145+
assert order.allocation['sku2'] == shipment
146146

147147

148148
def test_cannot_allocate_if_insufficent_quantity_in_stock():
@@ -151,7 +151,7 @@ def test_cannot_allocate_if_insufficent_quantity_in_stock():
151151

152152
order.allocate(stock, shipments=[])
153153

154-
assert 'a-sku' not in order.allocations
154+
assert 'a-sku' not in order.allocation
155155

156156

157157
def test_cannot_allocate_if_insufficent_quantity_in_shipment():
@@ -162,5 +162,5 @@ def test_cannot_allocate_if_insufficent_quantity_in_shipment():
162162

163163
order.allocate(stock=Stock({}), shipments=[shipment])
164164

165-
assert 'a-sku' not in order.allocations
165+
assert 'a-sku' not in order.allocation
166166

0 commit comments

Comments
 (0)