Add more coverage

This commit is contained in:
vrde 2017-08-09 16:23:03 +02:00
parent 05ff9cd61f
commit c4853f54b9
No known key found for this signature in database
GPG Key ID: 6581C7C39B3D397D
2 changed files with 21 additions and 1 deletions

View File

@ -82,7 +82,7 @@ class Exchange:
while True:
event = self.publisher_queue.get()
if event is POISON_PILL:
if event == POISON_PILL:
return
else:
self.dispatch(event)

View File

@ -33,3 +33,23 @@ def test_event_handler():
assert event_sub2.data == event.data
assert sub3.qsize() == 0
def test_exchange_stops_with_poison_pill():
from bigchaindb.events import EventTypes, Event, Exchange, POISON_PILL
# create and event
event_data = {'msg': 'some data'}
event = Event(EventTypes.BLOCK_VALID, event_data)
# create the events pub sub
exchange = Exchange()
publisher_queue = exchange.get_publisher_queue()
# push and event to the queue
publisher_queue.put(event)
publisher_queue.put(POISON_PILL)
exchange.run()
assert publisher_queue.qsize() == 0