
284
2
부
이벤트 기반 아키텍처
publish: Callable = redis_eventpublisher.publish,
) -> messagebus.MessageBus:
13.9.2
테스트를 위한 가짜 버전 만들기
더 나아가 단위 테스트를 위한 가짜 버전을 정의해본다.
가짜 통지(
tests
/
unit
/
test
_
handlers
.
py
)
class FakeNotifications(notifications.AbstractNotifications):
def __init__(self):
self.sent = defaultdict(list) # type: Dict[str, List[str]]
def send(self, destination, message):
self.sent[destination].append(message)
...
테스트 시 사용한다.
테스트를 약간 바꿔야 한다(
tests
/
unit
/
test
_
handlers
.
py
)
def test_sends_email_on_out_of_stock_error(self):
fake_notifs = FakeNotifications()
bus = bootstrap.bootstrap(
start_orm=False,
uow=FakeUnitOfWork(),
notifications=fake_notifs,
publish=lambda ...