#NEWLINE# def test_messages_are_delivered_to_processor_after_restarting( self ) : #NEWLINE# #INDENT# consumer = self . _create_consumer ( processor = 'test_processor' , connection = 'test_connection' ) #NEWLINE# consumer . startService ( ) #NEWLINE# mocked_processor = mock . Mock ( name = 'processor' ) #NEWLINE# consumer . processor_dependency . on_resource_ready ( mocked_processor ) #NEWLINE# message_queue = defer . DeferredQueue ( ) #NEWLINE# mocked_connection = mock . Mock ( name = 'connection' ) #NEWLINE# mocked_channel = mocked_connection . channel . return_value = mock . Mock ( name = 'channel' ) #NEWLINE# mocked_consumer_tag = mock . Mock ( name = 'consumer_tag' ) #NEWLINE# mocked_channel . basic_consume . return_value = ( message_queue , mocked_consumer_tag ) #NEWLINE# consumer . connection_dependency . on_resource_ready ( mocked_connection ) #NEWLINE# self . assertEquals ( mocked_processor . call_count , 0 ) #NEWLINE# message_queue . put ( ( mocked_channel , mock . Mock ( name = 'method' ) , mock . Mock ( name = 'properties' ) , 'test message body' ) ) #NEWLINE# self . assertEquals ( mocked_processor . call_count , 1 ) #NEWLINE# with patch . object ( providers . logger , 'warn' ) as mocked_warn : #NEWLINE# #INDENT# consumer . stopService ( ) #NEWLINE# consumer . startService ( ) #NEWLINE# #UNINDENT# self . assertEquals ( mocked_processor . call_count , 1 ) #NEWLINE# message_queue . put ( ( mocked_consumer_tag , mock . Mock ( name = 'method' ) , mock . Mock ( name = 'properties' ) , 'test message body' ) ) #NEWLINE# self . assertEquals ( mocked_processor . call_count , 2 )