|
1 | 1 | from datetime import date, timedelta |
2 | | -import pytest |
3 | | -from allocation import events, exceptions |
| 2 | +from allocation import events |
4 | 3 | from allocation.model import Product, OrderLine, Batch |
5 | 4 |
|
6 | 5 | today = date.today() |
@@ -42,23 +41,14 @@ def test_returns_allocated_batch_ref(): |
42 | 41 | assert allocation == in_stock_batch.reference |
43 | 42 |
|
44 | 43 |
|
45 | | -def test_raises_out_of_stock_exception_if_cannot_allocate(): |
| 44 | +def test_records_out_of_stock_event_if_cannot_allocate(): |
46 | 45 | batch = Batch('batch1', 'SMALL-FORK', 10, eta=today) |
47 | 46 | product = Product(sku="SMALL-FORK", batches=[batch]) |
48 | 47 | product.allocate(OrderLine('order1', 'SMALL-FORK', 10)) |
49 | 48 |
|
50 | | - with pytest.raises(exceptions.OutOfStock, match='SMALL-FORK'): |
51 | | - product.allocate(OrderLine('order2', 'SMALL-FORK', 1)) |
52 | | - |
53 | | - |
54 | | -def test_records_out_of_stock_event_if_cannot_allocate(): |
55 | | - sku1_batch = Batch('batch1', 'sku1', 100, eta=today) |
56 | | - sku2_line = OrderLine('oref', 'sku2', 10) |
57 | | - product = Product(sku='sku1', batches=[sku1_batch]) |
58 | | - |
59 | | - with pytest.raises(exceptions.OutOfStock): |
60 | | - product.allocate(sku2_line) |
61 | | - assert product.events[-1] == events.OutOfStock(sku='sku2') |
| 49 | + allocation = product.allocate(OrderLine('order2', 'SMALL-FORK', 1)) |
| 50 | + assert product.events[-1] == events.OutOfStock(sku="SMALL-FORK") |
| 51 | + assert allocation is None |
62 | 52 |
|
63 | 53 |
|
64 | 54 | def test_increments_version_number(): |
|
0 commit comments