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