def test_purge_plugins(): from sampleproject.toolkit.app import BaseApplication, MergedConfiguration app = BaseApplication() app.plugins = dict(destroyme=1, keepme=1) app.config = MergedConfiguration() app.config.update(dict(temboard=dict(plugins=['keepme']))) app.purge_plugins() assert 'destroyme' not in app.plugins
def test_apply_config_without_plugins(mocker): mod = 'sampleproject.toolkit.app.' mocker.patch(mod + 'BaseApplication.setup_logging', autospec=True) from sampleproject.toolkit.app import BaseApplication app = BaseApplication(with_plugins=False) app.config_sources = dict() app.config = mocker.Mock(name='config') app.apply_config() assert app.setup_logging.called is True
def test_reload(mocker): m = 'sampleproject.toolkit.app.BaseApplication' mocker.patch(m + '.read_file', autospec=True) mocker.patch(m + '.read_dir', autospec=True) mocker.patch(m + '.apply_config', autospec=True) from sampleproject.toolkit.app import BaseApplication app = BaseApplication() app.config = mocker.Mock(name='config') app.config.temboard.configfile = 'pouet.conf' app.reload()
def test_create_plugins(mocker): mod = 'sampleproject.toolkit.app' mocker.patch(mod + '.refresh_distributions') mocker.patch(mod + '.refresh_pythonpath') mocker.patch(mod + '.BaseApplication.fetch_plugin', autospec=True) from sampleproject.toolkit.app import BaseApplication app = BaseApplication() app.config = mocker.Mock(name='config') app.config.temboard.plugins = ['ng'] app.create_plugins() assert 'ng' in app.plugins
def test_apply_config_with_plugins(mocker): mod = 'sampleproject.toolkit.app.' mocker.patch(mod + 'BaseApplication.setup_logging', autospec=True) cp = mocker.patch(mod + 'BaseApplication.create_plugins', autospec=True) mocker.patch(mod + 'BaseApplication.update_plugins', autospec=True) mocker.patch(mod + 'BaseApplication.purge_plugins', autospec=True) from sampleproject.toolkit.app import BaseApplication app = BaseApplication() app.config_sources = dict() app.config = mocker.Mock(name='config') app.services.append(mocker.Mock(name='service')) cp.return_value = ['plugin'] app.apply_config() assert app.setup_logging.called is True assert app.update_plugins.called is True assert app.purge_plugins.called is True