Skip to content

Commit d75eaf7

Browse files
committed
test out of stock exception [test_out_of_stock]
1 parent 18aa3b4 commit d75eaf7

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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)
@@ -36,3 +37,11 @@ def test_returns_allocated_batch_ref():
3637
line = OrderLine("oref", "HIGHBROW-POSTER", 10)
3738
allocation = allocate(line, [in_stock_batch, shipment_batch])
3839
assert allocation == in_stock_batch.reference
40+
41+
42+
def test_raises_out_of_stock_exception_if_cannot_allocate():
43+
batch = Batch("batch1", "SMALL-FORK", 10, eta=today)
44+
allocate(OrderLine("order1", "SMALL-FORK", 10), [batch])
45+
46+
with pytest.raises(OutOfStock, match="SMALL-FORK"):
47+
allocate(OrderLine("order2", "SMALL-FORK", 1), [batch])

0 commit comments

Comments
 (0)