Skip to content

Commit 6e6937c

Browse files
committed
Revert fake messagebus stuff [chapter_09_all_messagebus_ends]
This reverts commit 8f2c36f. This reverts commit d398811.
1 parent 68ce401 commit 6e6937c

1 file changed

Lines changed: 0 additions & 37 deletions

File tree

‎tests/unit/test_handlers.py‎

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# pylint: disable=no-self-use
22
from datetime import date
33
from unittest import mock
4-
from typing import List
54
import pytest
65

76
from allocation.adapters import repository
@@ -127,39 +126,3 @@ def test_reallocates_if_necessary(self):
127126
assert batch1.available_quantity == 5
128127
# and 20 will be reallocated to the next batch
129128
assert batch2.available_quantity == 30
130-
131-
132-
class FakeUnitOfWorkWithFakeMessageBus(FakeUnitOfWork):
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-
event_history = [
148-
events.BatchCreated("batch1", "INDIFFERENT-TABLE", 50, None),
149-
events.BatchCreated("batch2", "INDIFFERENT-TABLE", 50, date.today()),
150-
events.AllocationRequired("order1", "INDIFFERENT-TABLE", 20),
151-
events.AllocationRequired("order2", "INDIFFERENT-TABLE", 20),
152-
]
153-
for e in event_history:
154-
messagebus.handle(e, uow)
155-
[batch1, batch2] = uow.products.get(sku="INDIFFERENT-TABLE").batches
156-
assert batch1.available_quantity == 10
157-
assert batch2.available_quantity == 50
158-
159-
messagebus.handle(events.BatchQuantityChanged("batch1", 25), uow)
160-
161-
# assert on new events emitted rather than downstream side-effects
162-
[reallocation_event] = uow.events_published
163-
assert isinstance(reallocation_event, events.AllocationRequired)
164-
assert reallocation_event.orderid in {"order1", "order2"}
165-
assert reallocation_event.sku == "INDIFFERENT-TABLE"

0 commit comments

Comments
 (0)