Skip to content

Commit f8ed253

Browse files
committed
sort-of fake messagebus on fake-uow. [fake_messagebus]
1 parent f7350a8 commit f8ed253

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/unit/test_handlers.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from datetime import date
22
from unittest import mock
3+
from typing import List
34
import pytest
45
from allocation import events, exceptions, messagebus, repository, unit_of_work
56

@@ -122,3 +123,15 @@ def test_reallocates_if_necessary():
122123
assert batch1.available_quantity == 5
123124
# and 20 will be reallocated to the next batch
124125
assert batch2.available_quantity == 30
126+
127+
128+
class FakeUnitOfWorkWithFakeMessageBus(FakeUnitOfWork):
129+
130+
def __init__(self):
131+
super().__init__()
132+
self.events_published = [] # type: List[events.Event]
133+
134+
def publish_events(self):
135+
for product in self.products.seen:
136+
while product.events:
137+
self.events_published.append(product.events.pop(0))

0 commit comments

Comments
 (0)