示例#1
0
def test_apply_config_bad_logging(mocker):
    mod = 'sampleproject.toolkit.app.'
    sl = mocker.patch(mod + 'setup_logging', autospec=True)
    from sampleproject.toolkit.app import BaseApplication, UserError

    app = BaseApplication()
    app.config.logging = dict()
    sl.side_effect = Exception('pouet')

    with pytest.raises(UserError):
        app.apply_config()
示例#2
0
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
示例#3
0
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