def test_loader_should_ignore_if_there_is_no_such_app(imp, importlib): "Loader should ignore when the app does not exist" importlib.import_module.side_effect = AttributeError("there is no such module") Loader.import_listener_from_module("deal") importlib.import_module.assert_called_once_with("deal") assert not imp.find_module.called
def test_loader_start_maps_installed_apps(settings, import_listener_from_module): "Loader.start() should ignore when the app does not exist" settings.INSTALLED_APPS = ["chuck", "norris"] Loader.start() import_listener_from_module.assert_has_calls([call("chuck"), call("norris")])
def test_loader_should_be_able_to_load_a_single_module(imp, importlib): u"Loader should be able to load a listener from a module" importlib.import_module.return_value.__path__ = "/some/path" Loader.import_listener_from_module("deal") imp.find_module.assert_called_once_with("listeners", "/some/path") importlib.import_module.assert_has_calls([call("deal"), call("deal.listeners")])
def test_loader_should_ignore_if_there_is_no_such_app(imp, importlib): "Loader should ignore when the app does not exist" importlib.import_module.side_effect = ( AttributeError('there is no such module')) Loader.import_listener_from_module('deal') importlib.import_module.assert_called_once_with('deal') assert not imp.find_module.called
def test_loader_should_ignore_if_there_are_no_listeners(imp, importlib): "Loader should ignore when the app does not exist" importlib.import_module.return_value.__path__ = "/some/path" imp.find_module.side_effect = ImportError("LOL") Loader.import_listener_from_module("deal") importlib.import_module.assert_called_once_with("deal") imp.find_module.assert_called_once_with("listeners", "/some/path")
def test_loader_should_ignore_if_there_are_no_listeners(imp, importlib): "Loader should ignore when the app does not exist" importlib.import_module.return_value.__path__ = '/some/path' imp.find_module.side_effect = ImportError('LOL') Loader.import_listener_from_module('deal') importlib.import_module.assert_called_once_with('deal') imp.find_module.assert_called_once_with('listeners', '/some/path')
def test_loader_should_be_able_to_load_a_single_module(imp, importlib): u"Loader should be able to load a listener from a module" importlib.import_module.return_value.__path__ = '/some/path' Loader.import_listener_from_module('deal') imp.find_module.assert_called_once_with('listeners', '/some/path') importlib.import_module.assert_has_calls([ call('deal'), call('deal.listeners'), ])
def test_loader_start_maps_installed_apps(settings, import_listener_from_module): "Loader.start() should ignore when the app does not exist" settings.INSTALLED_APPS = ['chuck', 'norris'] Loader.start() import_listener_from_module.assert_has_calls([ call('chuck'), call('norris'), ])
def connect_all_signals(): Loader.start() for (signal, listener, args, kw) in signal_registry: signal.connect(listener, *args, **kw)