예제 #1
0
    def test_bootstrap_initialise(self):
        """
        Test the PluginManager.bootstrap_initialise() method
        """
        # GIVEN: A plugin manager with some mocked out methods
        manager = PluginManager()

        with patch.object(manager, 'find_plugins') as mocked_find_plugins, \
                patch.object(manager, 'hook_settings_tabs') as mocked_hook_settings_tabs, \
                patch.object(manager, 'hook_media_manager') as mocked_hook_media_manager, \
                patch.object(manager, 'hook_import_menu') as mocked_hook_import_menu, \
                patch.object(manager, 'hook_export_menu') as mocked_hook_export_menu, \
                patch.object(manager, 'hook_tools_menu') as mocked_hook_tools_menu, \
                patch.object(manager, 'initialise_plugins') as mocked_initialise_plugins:
            # WHEN: bootstrap_initialise() is called
            manager.bootstrap_initialise()

        # THEN: The hook methods should have been called
        mocked_find_plugins.assert_called_with()
        mocked_hook_settings_tabs.assert_called_with()
        mocked_hook_media_manager.assert_called_with()
        mocked_hook_import_menu.assert_called_with()
        mocked_hook_export_menu.assert_called_with()
        mocked_hook_tools_menu.assert_called_with()
        mocked_initialise_plugins.assert_called_with()
예제 #2
0
    def test_find_plugins(self, mocked_is1, mocked_is2, mocked_is3, mocked_is4,
                          mocked_is5):
        """
        Test the find_plugins() method to ensure it imports the correct plugins
        """
        # GIVEN: A plugin manager
        plugin_manager = PluginManager()
        plugin_manager.bootstrap_initialise()

        # WHEN: We mock out sys.platform to make it return "darwin" and then find the plugins
        old_platform = sys.platform
        sys.platform = 'darwin'
        sys.platform = old_platform

        # THEN: We should find the "Songs", "Bibles", etc in the plugins list
        plugin_names = [plugin.name for plugin in State().list_plugins()]
        assert 'songs' in plugin_names, 'There should be a "songs" plugin'
        assert 'bibles' in plugin_names, 'There should be a "bibles" plugin'
        assert 'presentations' in plugin_names, 'There should be a "presentations" plugin'
        assert 'images' in plugin_names, 'There should be a "images" plugin'
        assert 'media' in plugin_names, 'There should be a "media" plugin'
        assert 'custom' in plugin_names, 'There should be a "custom" plugin'
        assert 'songusage' in plugin_names, 'There should be a "songusage" plugin'
        assert 'alerts' in plugin_names, 'There should be a "alerts" plugin'