Skip to content

Commit 8c8c1f5

Browse files
committed
all service-layer tests now services [services_tests_all_services]
1 parent b7e15c4 commit 8c8c1f5

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

test_services.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@
66

77
class FakeRepository(repository.AbstractRepository):
88

9-
@staticmethod
10-
def for_batch(ref, sku, qty, eta=None):
11-
return FakeRepository([
12-
model.Batch(ref, sku, qty, eta),
13-
])
14-
159
def __init__(self, batches):
1610
self._batches = set(batches)
1711

@@ -34,25 +28,29 @@ def commit(self):
3428

3529
def test_add_batch():
3630
repo, session = FakeRepository([]), FakeSession()
37-
services.add_batch('b1', 'CRUNCHY-ARMCHAIR', 100, None, repo, session)
38-
assert repo.get('b1') is not None
31+
services.add_batch("b1", "CRUNCHY-ARMCHAIR", 100, None, repo, session)
32+
assert repo.get("b1") is not None
3933
assert session.committed
4034

4135

42-
def test_returns_allocation():
43-
repo = FakeRepository.for_batch("batch1", "COMPLICATED-LAMP", 100, eta=None)
44-
result = services.allocate("o1", "COMPLICATED-LAMP", 10, repo, FakeSession())
36+
def test_allocate_returns_allocation():
37+
repo, session = FakeRepository([]), FakeSession()
38+
services.add_batch("batch1", "COMPLICATED-LAMP", 100, None, repo, session)
39+
result = services.allocate("o1", "COMPLICATED-LAMP", 10, repo, session)
4540
assert result == "batch1"
4641

4742

48-
def test_error_for_invalid_sku():
49-
repo = FakeRepository.for_batch('b1', 'AREALSKU', 100, eta=None)
43+
def test_allocate_errors_for_invalid_sku():
44+
repo, session = FakeRepository([]), FakeSession()
45+
services.add_batch("b1", "AREALSKU", 100, None, repo, session)
46+
5047
with pytest.raises(services.InvalidSku, match="Invalid sku NONEXISTENTSKU"):
5148
services.allocate("o1", "NONEXISTENTSKU", 10, repo, FakeSession())
5249

5350

5451
def test_commits():
55-
repo = FakeRepository.for_batch("b1", "OMINOUS-MIRROR", 100, eta=None)
52+
repo, session = FakeRepository([]), FakeSession()
5653
session = FakeSession()
54+
services.add_batch("b1", "OMINOUS-MIRROR", 100, None, repo, session)
5755
services.allocate("o1", "OMINOUS-MIRROR", 10, repo, session)
5856
assert session.committed is True

0 commit comments

Comments
 (0)