Skip to content

Commit a1903fa

Browse files
committed
first tests for the services layer [first_services_tests]
1 parent 80dece9 commit a1903fa

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test_services.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
3+
import model
4+
import services
5+
6+
7+
def test_returns_allocation():
8+
line = model.OrderLine("o1", "COMPLICATED-LAMP", 10)
9+
batch = model.Batch("b1", "COMPLICATED-LAMP", 100, eta=None)
10+
repo = FakeRepository([batch])
11+
12+
result = services.allocate(line, repo, FakeSession())
13+
assert result == "b1"
14+
15+
16+
def test_error_for_invalid_sku():
17+
line = model.OrderLine("o1", "NONEXISTENTSKU", 10)
18+
batch = model.Batch("b1", "AREALSKU", 100, eta=None)
19+
repo = FakeRepository([batch])
20+
21+
with pytest.raises(services.InvalidSku, match="Invalid sku NONEXISTENTSKU"):
22+
services.allocate(line, repo, FakeSession())

0 commit comments

Comments
 (0)