#NEWLINE# def test_event_handler( queue_consumer , mock_container ) : #NEWLINE# #INDENT# container = mock_container #NEWLINE# container . service_name = 'destservice' #NEWLINE# event_handler = EventHandler ( 'srcservice' , 'eventtype' ) . bind ( container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# assert ( event_handler . queue . durable is True ) #NEWLINE# assert ( event_handler . queue . routing_key == 'eventtype' ) #NEWLINE# assert ( event_handler . queue . exchange . name == 'srcservice.events' ) #NEWLINE# queue_consumer . register_provider . assert_called_once_with ( event_handler ) #NEWLINE# event_handler = EventHandler ( 'srcservice' , 'eventtype' ) . bind ( container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# assert ( event_handler . queue . name == 'evt-srcservice-eventtype--destservice.foobar' ) #NEWLINE# assert ( event_handler . queue . exclusive is False ) #NEWLINE# with patch ( 'nameko.events.uuid' ) as mock_uuid : #NEWLINE# #INDENT# mock_uuid . uuid4 ( ) . hex = 'uuid-value' #NEWLINE# event_handler = EventHandler ( 'srcservice' , 'eventtype' , handler_type = BROADCAST , reliable_delivery = False ) . bind ( container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# #UNINDENT# assert ( event_handler . queue . name == 'evt-srcservice-eventtype--destservice.foobar-{}' . format ( 'uuid-value' ) ) #NEWLINE# assert ( event_handler . queue . exclusive is True ) #NEWLINE# class BroadcastEventHandler ( EventHandler ) : #NEWLINE# #INDENT# broadcast_identifier = 'testbox' #NEWLINE# #UNINDENT# event_handler = BroadcastEventHandler ( 'srcservice' , 'eventtype' , handler_type = BROADCAST ) . bind ( container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# assert ( event_handler . queue . name == 'evt-srcservice-eventtype--destservice.foobar-{}' . format ( 'testbox' ) ) #NEWLINE# assert ( event_handler . queue . exclusive is False ) #NEWLINE# event_handler = EventHandler ( 'srcservice' , 'eventtype' , handler_type = SINGLETON ) . bind ( mock_container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# assert ( event_handler . queue . name == 'evt-srcservice-eventtype' ) #NEWLINE# assert ( event_handler . queue . exclusive is False ) #NEWLINE# event_handler = EventHandler ( 'srcservice' , 'eventtype' ) . bind ( container , 'foobar' ) #NEWLINE# event_handler . setup ( ) #NEWLINE# assert ( event_handler . queue . auto_delete is False )