Exemplo n.º 1
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
Exemplo n.º 2
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