def test_fetch_missing(mocker): iter_ep = mocker.patch('temboardagent.cli.iter_entry_points') from temboardagent.cli import Application, UserError app = Application() iter_ep.return_value = [] with pytest.raises(UserError): app.fetch_plugin('myplugin')
def test_fetch_failing(mocker): iter_ep = mocker.patch('temboardagent.cli.iter_entry_points') from temboardagent.cli import Application, UserError app = Application() 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('temboardagent.cli.iter_entry_points') from temboardagent.cli import Application app = Application() 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'])