Skip to content

Commit 7987fbf

Browse files
committed
Revert fake messagebus stuff [chapter_08_all_messagebus_ends]
This reverts commit 8f2c36f. This reverts commit d398811.
1 parent ddc98b1 commit 7987fbf

1 file changed

Lines changed: 0 additions & 34 deletions

File tree

‎tests/unit/test_handlers.py‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
from datetime import date
22
from unittest import mock
3-
from typing import List
43
import pytest
54

65
from allocation.adapters import repository
@@ -126,36 +125,3 @@ def test_reallocates_if_necessary():
126125
assert batch1.available_quantity == 5
127126
# and 20 will be reallocated to the next batch
128127
assert batch2.available_quantity == 30
129-
130-
131-
class FakeUnitOfWorkWithFakeMessageBus(FakeUnitOfWork):
132-
133-
def __init__(self):
134-
super().__init__()
135-
self.events_published = [] # type: List[events.Event]
136-
137-
def publish_events(self):
138-
for product in self.products.seen:
139-
while product.events:
140-
self.events_published.append(product.events.pop(0))
141-
142-
143-
def test_reallocates_if_necessary_isolated():
144-
uow = FakeUnitOfWorkWithFakeMessageBus()
145-
146-
# test setup as before
147-
messagebus.handle(events.BatchCreated("batch1", "INDIFFERENT-TABLE", 50, None), uow)
148-
messagebus.handle(events.BatchCreated("batch2", "INDIFFERENT-TABLE", 50, date.today()), uow)
149-
messagebus.handle(events.AllocationRequired("order1", "INDIFFERENT-TABLE", 20), uow)
150-
messagebus.handle(events.AllocationRequired("order2", "INDIFFERENT-TABLE", 20), uow)
151-
[batch1, batch2] = uow.products.get(sku="INDIFFERENT-TABLE").batches
152-
assert batch1.available_quantity == 10
153-
154-
messagebus.handle(events.BatchQuantityChanged("batch1", 25), uow)
155-
156-
# assert on new events emitted rather than downstream side-effects
157-
[reallocation_event] = uow.events_published
158-
assert isinstance(reallocation_event, events.AllocationRequired)
159-
assert reallocation_event.orderid in {'order1', 'order2'}
160-
assert reallocation_event.sku == 'INDIFFERENT-TABLE'
161-

0 commit comments

Comments
 (0)