Skip to content

Commit d82358c

Browse files
committed
test out of stock exception [test_out_of_stock]
1 parent 886d9b8 commit d82358c

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

test_allocate.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import date, timedelta
2-
from model import allocate, OrderLine, Batch
2+
import pytest
3+
from model import allocate, OrderLine, Batch, OutOfStock
34

45
today = date.today()
56
tomorrow = today + timedelta(days=1)
@@ -35,3 +36,11 @@ def test_returns_allocated_batch_ref():
3536
line = OrderLine("oref", "HIGHBROW-POSTER", 10)
3637
allocation = allocate(line, [in_stock_batch, shipment_batch])
3738
assert allocation == in_stock_batch.reference
39+
40+
41+
def test_raises_out_of_stock_exception_if_cannot_allocate():
42+
batch = Batch('batch1', 'HEAVY-SPOON', 100, eta=today)
43+
different_sku_line = OrderLine('oref', 'SMALL-FORK', 10)
44+
45+
with pytest.raises(OutOfStock, match='SMALL-FORK'):
46+
allocate(different_sku_line, [batch])

0 commit comments

Comments
 (0)