Skip to content

Commit 0449180

Browse files
committed
Revert fake messagebus stuff [chapter_08_all_messagebus_ends]
This reverts commit 8f2c36f. This reverts commit d398811.
1 parent 58fd37d commit 0449180

File tree

1 file changed

+0
-34
lines changed

1 file changed

+0
-34
lines changed

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
from allocation import events, exceptions, messagebus, repository, unit_of_work
65

@@ -123,36 +122,3 @@ def test_reallocates_if_necessary():
123122
assert batch1.available_quantity == 5
124123
# and 20 will be reallocated to the next batch
125124
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))
138-
139-
140-
def test_reallocates_if_necessary_isolated():
141-
uow = FakeUnitOfWorkWithFakeMessageBus()
142-
143-
# test setup as before
144-
messagebus.handle(events.BatchCreated("batch1", "INDIFFERENT-TABLE", 50, None), uow)
145-
messagebus.handle(events.BatchCreated("batch2", "INDIFFERENT-TABLE", 50, date.today()), uow)
146-
messagebus.handle(events.AllocationRequired("order1", "INDIFFERENT-TABLE", 20), uow)
147-
messagebus.handle(events.AllocationRequired("order2", "INDIFFERENT-TABLE", 20), uow)
148-
[batch1, batch2] = uow.products.get(sku="INDIFFERENT-TABLE").batches
149-
assert batch1.available_quantity == 10
150-
151-
messagebus.handle(events.BatchQuantityChanged("batch1", 25), uow)
152-
153-
# assert on new events emitted rather than downstream side-effects
154-
[reallocation_event] = uow.events_published
155-
assert isinstance(reallocation_event, events.AllocationRequired)
156-
assert reallocation_event.orderid in {'order1', 'order2'}
157-
assert reallocation_event.sku == 'INDIFFERENT-TABLE'
158-

0 commit comments

Comments
 (0)