Skip to content

Commit 41240ab

Browse files
committed
Ugly hack for messagebus to return results [hack_messagebus_results]
1 parent 2910812 commit 41240ab

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎src/allocation/messagebus.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@
66

77

88
def handle(event: events.Event, uow: unit_of_work.AbstractUnitOfWork):
9+
results = []
910
for handler in HANDLERS[type(event)]:
10-
handler(event, uow=uow)
11+
r = handler(event, uow=uow)
12+
results.append(r)
13+
return results
14+
1115

1216

1317
HANDLERS = {

‎tests/unit/test_handlers.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ class TestAllocate:
5454
def test_returns_allocation():
5555
uow = FakeUnitOfWork()
5656
messagebus.handle(events.BatchCreated("b1", "COMPLICATED-LAMP", 100, None), uow)
57-
result = messagebus.handle(events.AllocationRequired("o1", "COMPLICATED-LAMP", 10), uow)
58-
assert result == "b1"
57+
results = messagebus.handle(events.AllocationRequired("o1", "COMPLICATED-LAMP", 10), uow)
58+
assert results.pop() == "b1"
5959

6060
@staticmethod
6161
def test_errors_for_invalid_sku():

0 commit comments

Comments
 (0)