|
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(): |
46 |
| - batch = Batch('batch1', 'HEAVY-SPOON', 100, eta=today) |
47 |
| - different_sku_line = OrderLine('oref', 'SMALL-FORK', 10) |
48 |
| - product = Product(sku="HIGHBROW-POSTER", batches=[batch]) |
49 |
| - |
50 |
| - with pytest.raises(exceptions.OutOfStock, match='SMALL-FORK'): |
51 |
| - product.allocate(different_sku_line) |
52 |
| - |
53 |
| - |
54 | 44 | 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]) |
| 45 | + batch = Batch("batch1", "HEAVY-SPOON", 100, eta=today) |
| 46 | + different_sku_line = OrderLine("oref", "SMALL-FORK", 10) |
| 47 | + product = Product(sku="HEAVY-SPOON", batches=[batch]) |
58 | 48 |
|
59 |
| - with pytest.raises(exceptions.OutOfStock): |
60 |
| - product.allocate(sku2_line) |
61 |
| - assert product.events[-1] == events.OutOfStock(sku='sku2') |
| 49 | + allocation = product.allocate(different_sku_line) |
| 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