def test_importing_events(import_module, settings): settings.INSTALLED_APPS = ['foobar', 'test_app'] core.import_event_modules() calls = [call('foobar.events'), call('test_app.events')] import_module.assert_has_calls(calls) settings.INSTALLED_APPS = ['tester'] import_module.side_effect = ImportError('P0wned!!!') core.import_event_modules()
def listen_for_events(): """Pubsub event listener Listen for events in the pubsub bus and calls the process function when somebody comes to play. """ import_event_modules() conn = redis_connection.get_connection() pubsub = conn.pubsub() pubsub.subscribe("eventlib") for message in pubsub.listen(): if message['type'] != 'message': continue data = loads(message["data"]) if 'name' in data: event_name = data.pop('name') process_external(event_name, data)