def test_hook_errs( self ):
        """should fail gracefully if hook fails (and continue with other plugins)"""
        mock_app_dir = mock.MockDir({
            'plugins'   : {
                'plugin1'   : {
                    loading_point : contents5
                },
                'plugin2'   : {
                    loading_point : contents6
                },
                'plugin3'   : {
                    loading_point : contents7
                }
            }
        })
        mock_app = mock.MockApp( mock_app_dir.root_path )
        plugin_mgr = HookPluginManager( mock_app, directories_setting='plugins', skip_bad_plugins=False )
        app_path = mock_app_dir.root_path
        expected_plugins_path = os.path.join( app_path, 'plugins' )
        self.assertItemsEqual( plugin_mgr.plugins.keys(), [ 'plugin1', 'plugin2', 'plugin3' ] )

        return_val_dict = plugin_mgr.run_hook( 'blah', 'one two check' )
        self.assertEqual( return_val_dict, { 'plugin1' : 'One Two Check', 'plugin2' : 'ONE TWO CHECK' } )

        result = plugin_mgr.filter_hook( 'filter_test', 'check' )
        self.assertEqual( result, 'check one two' )

        mock_app_dir.remove()
Beispiel #2
0
    def test_run_hooks(self):
        """should run hooks of loaded plugins"""
        mock_app_dir = galaxy_mock.MockDir({
            'plugins': {
                'plugin1': {
                    loading_point: contents5
                },
                'plugin2': {
                    loading_point: contents6
                }
            }
        })
        mock_app = galaxy_mock.MockApp(root=mock_app_dir.root_path)
        plugin_mgr = HookPluginManager(mock_app,
                                       directories_setting='plugins',
                                       skip_bad_plugins=False)
        self.assertItemsEqual(plugin_mgr.plugins.keys(),
                              ['plugin1', 'plugin2'])

        return_val_dict = plugin_mgr.run_hook('blah', 'one two check')
        self.assertEqual(return_val_dict, {
            'plugin1': 'One Two Check',
            'plugin2': 'ONE TWO CHECK'
        })

        result = plugin_mgr.filter_hook('filter_test', 'check')
        self.assertEqual(result, 'check one two')

        mock_app_dir.remove()
    def test_run_hooks( self ):
        """should run hooks of loaded plugins"""
        mock_app_dir = galaxy_mock.MockDir({
            'plugins': {
                'plugin1': {
                    loading_point: contents5
                },
                'plugin2': {
                    loading_point: contents6
                }
            }
        })
        mock_app = galaxy_mock.MockApp( root=mock_app_dir.root_path )
        plugin_mgr = HookPluginManager( mock_app, directories_setting='plugins', skip_bad_plugins=False )
        self.assertEqual( sorted(plugin_mgr.plugins.keys()), [ 'plugin1', 'plugin2' ] )

        return_val_dict = plugin_mgr.run_hook( 'blah', 'one two check' )
        self.assertEqual( return_val_dict, { 'plugin1': 'One Two Check', 'plugin2': 'ONE TWO CHECK' } )

        result = plugin_mgr.filter_hook( 'filter_test', 'check' )
        self.assertEqual( result, 'check one two' )

        mock_app_dir.remove()