def test_read_events(settings, process_external, redis_connection): pubsub = redis_connection.get_connection.return_value.pubsub pubsub.return_value.listen.side_effect = gen listen_for_events() process_external.assert_has_calls([ call(u'app.TestEvent', {'a': 'b'}), call(u'app.TestEvent', {'a': 'b'}), ])
def test_read_events_skip_non_messages(settings, process_external, conn): # Given I mock the pubsub connection to return only messages with # types different from "message" pubsub = conn.get_connection.return_value.pubsub pubsub.return_value.listen.side_effect = gen_non_message_events # When I listen to the events listen_for_events() # Then No messages should be processed process_external.assert_has_calls([])
def handle(self, *args, **options): listen_for_events()