mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Add more coverage
This commit is contained in:
parent
05ff9cd61f
commit
c4853f54b9
@ -82,7 +82,7 @@ class Exchange:
|
|||||||
|
|
||||||
while True:
|
while True:
|
||||||
event = self.publisher_queue.get()
|
event = self.publisher_queue.get()
|
||||||
if event is POISON_PILL:
|
if event == POISON_PILL:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.dispatch(event)
|
self.dispatch(event)
|
||||||
|
@ -33,3 +33,23 @@ def test_event_handler():
|
|||||||
assert event_sub2.data == event.data
|
assert event_sub2.data == event.data
|
||||||
|
|
||||||
assert sub3.qsize() == 0
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user