Skip to content

Commit 6243106

Browse files
committed
hacky fix for uow integration tests
fixup bug in reallocate handler
1 parent b641cbe commit 6243106

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎tests/integration/test_uow.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from allocation.domain import model
88
from allocation.service_layer import unit_of_work
99
from ..random_refs import random_sku, random_batchref, random_orderid
10+
from unittest.mock import Mock
1011

1112

1213
def insert_batch(session, ref, sku, qty, eta, product_version=1):
@@ -40,6 +41,7 @@ def test_uow_can_retrieve_a_batch_and_allocate_to_it(sqlite_session_factory):
4041
session.commit()
4142

4243
uow = unit_of_work.SqlAlchemyUnitOfWork(sqlite_session_factory)
44+
uow.bus = Mock()
4345
with uow:
4446
product = uow.products.get(sku='HIPSTER-WORKBENCH')
4547
line = model.OrderLine('o1', 'HIPSTER-WORKBENCH', 10)
@@ -79,11 +81,12 @@ def try_to_allocate(orderid, sku, exceptions, session_factory):
7981
line = model.OrderLine(orderid, sku, 10)
8082
try:
8183
with unit_of_work.SqlAlchemyUnitOfWork(session_factory) as uow:
84+
uow.bus = Mock()
8285
product = uow.products.get(sku=sku)
8386
product.allocate(line)
8487
time.sleep(0.2)
8588
uow.commit()
86-
except Exception as e: # pylint: disable=broad-except
89+
except Exception as e: # pylint: disable=broad-except
8790
print(traceback.format_exc())
8891
exceptions.append(e)
8992

0 commit comments

Comments
 (0)