def test_fetch_missing(mocker): iter_ep = mocker.patch( 'sampleproject.toolkit.app.pkg_resources.iter_entry_points') from sampleproject.toolkit.app import BaseApplication, UserError app = BaseApplication() iter_ep.return_value = [] with pytest.raises(UserError): app.fetch_plugin('myplugin')
def test_fetch_failing(mocker): iter_ep = mocker.patch( 'sampleproject.toolkit.app.pkg_resources.iter_entry_points') from sampleproject.toolkit.app import BaseApplication, UserError app = BaseApplication() ep = mocker.Mock(name='ep') ep.load.side_effect = Exception('Pouet') iter_ep.return_value = [ep] with pytest.raises(UserError): app.fetch_plugin('myplugin')
def test_fetch_plugin(mocker): iter_ep = mocker.patch( 'sampleproject.toolkit.app.pkg_resources.iter_entry_points') from sampleproject.toolkit.app import BaseApplication app = BaseApplication() ep = mocker.Mock(name='found') ep.name = 'found' ep.load.return_value = 'PLUGIN OBJECT' iter_ep.return_value = [ep] assert 'PLUGIN OBJECT' == app.fetch_plugin(['found'])