|
1 | 1 | # pylint: disable=no-self-use |
2 | 2 | from datetime import date |
3 | 3 | from unittest import mock |
4 | | -from typing import List |
5 | 4 | import pytest |
6 | 5 |
|
7 | 6 | from allocation.adapters import repository |
@@ -127,38 +126,3 @@ def test_reallocates_if_necessary(self): |
127 | 126 | assert batch1.available_quantity == 5 |
128 | 127 | # and 20 will be reallocated to the next batch |
129 | 128 | 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 collect_new_events(self): |
138 | | - self.events_published += super().collect_new_events() |
139 | | - return [] |
140 | | - |
141 | | - |
142 | | -def test_reallocates_if_necessary_isolated(): |
143 | | - uow = FakeUnitOfWorkWithFakeMessageBus() |
144 | | - |
145 | | - # test setup as before |
146 | | - event_history = [ |
147 | | - events.BatchCreated("batch1", "INDIFFERENT-TABLE", 50, None), |
148 | | - events.BatchCreated("batch2", "INDIFFERENT-TABLE", 50, date.today()), |
149 | | - events.AllocationRequired("order1", "INDIFFERENT-TABLE", 20), |
150 | | - events.AllocationRequired("order2", "INDIFFERENT-TABLE", 20), |
151 | | - ] |
152 | | - for e in event_history: |
153 | | - messagebus.handle(e, uow) |
154 | | - [batch1, batch2] = uow.products.get(sku="INDIFFERENT-TABLE").batches |
155 | | - assert batch1.available_quantity == 10 |
156 | | - assert batch2.available_quantity == 50 |
157 | | - |
158 | | - messagebus.handle(events.BatchQuantityChanged("batch1", 25), uow) |
159 | | - |
160 | | - # assert on new events emitted rather than downstream side-effects |
161 | | - [reallocation_event] = uow.events_published |
162 | | - assert isinstance(reallocation_event, events.AllocationRequired) |
163 | | - assert reallocation_event.orderid in {"order1", "order2"} |
164 | | - assert reallocation_event.sku == "INDIFFERENT-TABLE" |
0 commit comments