def remove(self, argv): """ Remove a plugin. This method is smart enough to work with only the plugin name if it happens to be unique. If there is more than one plugin with the same name but in a different bundle it will exit with an error. """ path = argv.path name = argv.name bundle = argv.bundle with self.out() as out: config = get_jigconfig(path) pm = PluginManager(config) plugins = plugins_by_name(pm) # Find the bundle if it's not specified if name in plugins and not bundle: if len(plugins[name]) > 1: # There are more than one plugin by this name raise CommandError( 'More than one plugin has the name of ' '{0}. Use the list command to see installed ' 'plugins.'.format(name)) bundle = plugins[name][0].bundle pm.remove(bundle, name) set_jigconfig(path, pm.config) out.append('Removed plugin {0}'.format(name))
def test_remove_non_existent_section(self): """ Try to remove a plugin that does not exist. """ pm = PluginManager(self.jigconfig) with self.assertRaises(PluginError) as ec: pm.remove('bundle', 'name') self.assertEqual('This plugin does not exist.', str(ec.exception))
def test_remove_plugin(self): """ Remove a plugin. """ pm = PluginManager(self.jigconfig) pm.add(join(self.fixturesdir, 'plugin01')) self.assertTrue(pm.config.has_section('plugin:test01:plugin01')) pm.remove('test01', 'plugin01') self.assertFalse(pm.config.has_section('plugin:test01:plugin01')) self.assertEqual([], pm.plugins)