Ejemplo n.º 1
0
def testLoadMultiplePluginsWithFailure(registry, logprint):
    plugin._loadPlugins(['plugin1', 'plugin2'], {})

    logprint.exception.assert_has_calls(
        [mock.call('Failed to load plugin plugin1')])
    assert 'plugin1' in plugin.getPluginFailureInfo()
    assert plugin.loadedPlugins() == ['plugin2']
Ejemplo n.º 2
0
def testLoadMultiplePluginsWithFailure(registry, logprint):
    plugin._loadPlugins(['plugin1', 'plugin2'], {})

    logprint.exception.assert_has_calls([
        mock.call('Failed to load plugin plugin1')
    ])
    assert 'plugin1' in plugin.getPluginFailureInfo()
    assert plugin.loadedPlugins() == ['plugin2']
Ejemplo n.º 3
0
def testLoadPluginWithError(registry, logprint):
    with pytest.raises(Exception) as exception1:
        plugin.getPlugin('throws').load({})

    logprint.exception.assert_called_once_with('Failed to load plugin throws')
    assert 'throws' in plugin.getPluginFailureInfo()

    with pytest.raises(Exception) as exception2:
        plugin.getPlugin('throws').load({})

    assert exception1.value is not exception2.value
Ejemplo n.º 4
0
def testLoadPluginWithError(registry, logprint):
    with pytest.raises(Exception) as exception1:
        plugin.getPlugin('throws').load({})

    logprint.exception.assert_called_once_with('Failed to load plugin throws')
    assert 'throws' in plugin.getPluginFailureInfo()

    with pytest.raises(Exception) as exception2:
        plugin.getPlugin('throws').load({})

    assert exception1.value is not exception2.value
Ejemplo n.º 5
0
    def getPlugins(self):
        def _pluginNameToResponse(name):
            p = plugin.getPlugin(name)
            return {
                'name': p.displayName,
                'description': p.description,
                'url': p.url,
                'version': p.version
            }

        plugins = {
            'all': {name: _pluginNameToResponse(name) for name in plugin.allPlugins()},
            'enabled': Setting().get(SettingKey.PLUGINS_ENABLED),
            'loaded': plugin.loadedPlugins()
        }
        failureInfo = {
            plugin: ''.join(traceback.format_exception(*exc_info))
            for plugin, exc_info in six.iteritems(plugin.getPluginFailureInfo())
        }

        if failureInfo:
            plugins['failed'] = failureInfo
        return plugins
Ejemplo n.º 6
0
    def getPlugins(self):
        def _pluginNameToResponse(name):
            p = plugin.getPlugin(name)
            return {
                'name': p.displayName,
                'description': p.description,
                'url': p.url,
                'version': p.version
            }

        plugins = {
            'all': {name: _pluginNameToResponse(name) for name in plugin.allPlugins()},
            'enabled': Setting().get(SettingKey.PLUGINS_ENABLED),
            'loaded': plugin.loadedPlugins()
        }
        failureInfo = {
            plugin: ''.join(traceback.format_exception(*exc_info))
            for plugin, exc_info in six.iteritems(plugin.getPluginFailureInfo())
        }

        if failureInfo:
            plugins['failed'] = failureInfo
        return plugins