|
1 | | -from domain_model import allocate |
| 1 | +from domain_model import Order, Stock |
2 | 2 |
|
3 | 3 |
|
4 | 4 | def test_can_allocate_to_stock(): |
5 | | - order = {'a-sku': 10} |
6 | | - stock = {'a-sku': 1000} |
| 5 | + order = Order({'a-sku': 10}) |
| 6 | + stock = Stock({'a-sku': 1000}) |
7 | 7 |
|
8 | | - allocations = allocate(order, stock, shipments=[]) |
| 8 | + order.allocate(stock, shipments=[]) |
9 | 9 |
|
10 | | - assert allocations['a-sku'] == stock |
| 10 | + assert order.allocations['a-sku'] == stock |
11 | 11 |
|
12 | 12 |
|
13 | 13 | def test_can_allocate_to_shipment(): |
14 | | - order = {'a-sku': 10} |
15 | | - shipment = {'a-sku': 1000} |
| 14 | + order = Order({'a-sku': 10}) |
| 15 | + shipment = Stock({'a-sku': 1000}) |
16 | 16 |
|
17 | | - allocations = allocate(order, stock={}, shipments=[shipment]) |
| 17 | + order.allocate(stock={}, shipments=[shipment]) |
18 | 18 |
|
19 | | - assert allocations['a-sku'] == shipment |
| 19 | + assert order.allocations['a-sku'] == shipment |
20 | 20 |
|
21 | 21 |
|
22 | 22 | def test_ignores_irrelevant_stock(): |
23 | | - order = {'sku1': 10} |
24 | | - stock = {'sku2': 1000} |
25 | | - shipment = {'sku1': 1000} |
| 23 | + order = Order({'sku1': 10}) |
| 24 | + stock = Stock({'sku2': 1000}) |
| 25 | + shipment = Stock({'sku1': 1000}) |
26 | 26 |
|
27 | | - allocations = allocate(order, stock=stock, shipments=[shipment]) |
| 27 | + order.allocate(stock=stock, shipments=[shipment]) |
| 28 | + |
| 29 | + assert order.allocations['sku1'] == shipment |
28 | 30 |
|
29 | | - assert allocations['sku1'] == shipment |
30 | 31 |
|
| 32 | +''' |
31 | 33 |
|
32 | 34 | def test_can_allocate_to_correct_shipment(): |
33 | 35 | order = {'sku2': 10} |
@@ -162,3 +164,4 @@ def test_cannot_allocate_if_insufficent_quantity_in_shipment(): |
162 | 164 |
|
163 | 165 | assert 'a-sku' not in allocations |
164 | 166 |
|
| 167 | +''' |
0 commit comments