|
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) |
@@ -44,23 +43,14 @@ def test_returns_allocated_batch_ref(): |
44 | 43 | assert allocation == in_stock_batch.reference |
45 | 44 |
|
46 | 45 |
|
47 | | -def test_raises_out_of_stock_exception_if_cannot_allocate(): |
| 46 | +def test_records_out_of_stock_event_if_cannot_allocate(): |
48 | 47 | batch = Batch("batch1", "SMALL-FORK", 10, eta=today) |
49 | 48 | product = Product(sku="SMALL-FORK", batches=[batch]) |
50 | 49 | product.allocate(OrderLine("order1", "SMALL-FORK", 10)) |
51 | 50 |
|
52 | | - with pytest.raises(OutOfStock, match="SMALL-FORK"): |
53 | | - product.allocate(OrderLine("order2", "SMALL-FORK", 1)) |
54 | | - |
55 | | - |
56 | | -def test_records_out_of_stock_event_if_cannot_allocate(): |
57 | | - sku1_batch = Batch("batch1", "sku1", 100, eta=today) |
58 | | - sku2_line = OrderLine("oref", "sku2", 10) |
59 | | - product = Product(sku="sku1", batches=[sku1_batch]) |
60 | | - |
61 | | - with pytest.raises(OutOfStock): |
62 | | - product.allocate(sku2_line) |
63 | | - assert product.events[-1] == events.OutOfStock(sku="sku2") |
| 51 | + allocation = product.allocate(OrderLine("order2", "SMALL-FORK", 1)) |
| 52 | + assert product.events[-1] == events.OutOfStock(sku="SMALL-FORK") |
| 53 | + assert allocation is None |
64 | 54 |
|
65 | 55 |
|
66 | 56 | def test_increments_version_number(): |
|
0 commit comments