Beispiel #1
0
 def setUp(self):
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \
             patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \
             patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \
             patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.mocked_settings_form = mocked_settings_form
         self.mocked_image_manager = mocked_image_manager
         self.mocked_live_controller = mocked_live_controller
         self.mocked_preview_controller = mocked_preview_controller
         self.mocked_dock_widget = mocked_dock_widget
         self.mocked_q_tool_box_class = mocked_q_tool_box_class
         self.mocked_add_dock_method = mocked_add_dock_method
         self.mocked_theme_manager = mocked_theme_manager
         self.mocked_renderer = mocked_renderer
         self.main_window = MainWindow()
Beispiel #2
0
    def test_registry_function(self):
        """
        Test the registry function creation and their usages
        """
        # GIVEN: An existing registry register a function
        Registry.create()
        Registry().register_function('test1', self.dummy_function_1)

        # WHEN: I execute the function
        return_value = Registry().execute('test1')

        # THEN: I expect then function to have been called and a return given
        assert return_value[0] == 'function_1', 'A return value is provided and matches'

        # WHEN: I execute the a function with the same reference and execute the function
        Registry().register_function('test1', self.dummy_function_1)
        return_value = Registry().execute('test1')

        # THEN: I expect then function to have been called and a return given
        assert return_value == ['function_1', 'function_1'], 'A return value list is provided and matches'

        # WHEN: I execute the a 2nd function with the different reference and execute the function
        Registry().register_function('test2', self.dummy_function_2)
        return_value = Registry().execute('test2')

        # THEN: I expect then function to have been called and a return given
        assert return_value[0] == 'function_2', 'A return value is provided and matches'
Beispiel #3
0
    def test_registry_service(self):
        """
        Test the registry creation and its usage
        """
        # GIVEN: A new registry
        Registry.create()

        # WHEN: I add a component it should save it
        mock_1 = MagicMock()
        Registry().register('test1', mock_1)

        # THEN: we should be able retrieve the saved component
        assert Registry().get('test1') == mock_1, 'The saved service can be retrieved and matches'

        # WHEN: I add a component for the second time I am mad.
        # THEN  and I will get an exception
        with self.assertRaises(KeyError) as context:
            Registry().register('test1', mock_1)
        assert context.exception.args[0] == 'Duplicate service exception test1', \
            'KeyError exception should have been thrown for duplicate service'

        # WHEN I try to get back a non existent component
        # THEN I will get an exception
        temp = Registry().get('test2')
        assert temp is None, 'None should have been returned for missing service'

        # WHEN I try to replace a component I should be allowed
        Registry().remove('test1')
        # THEN I will get an exception
        temp = Registry().get('test1')
        assert temp is None, 'None should have been returned for deleted service'
Beispiel #4
0
    def setUp(self):
        self.sample_theme_data = {
            'file_name': 'BlueBurst.otz',
            'sha256': 'sha_256_hash',
            'thumbnail': 'BlueBurst.png',
            'title': 'Blue Burst'
        }
        Registry.create()
        self.registry = Registry()
        mocked_app = MagicMock()
        mocked_app.worker_threads = {}
        Registry().register('application', mocked_app)
        self.setup_application()

        move_to_thread_patcher = patch(
            'openlp.core.ui.firsttimeform.DownloadWorker.moveToThread')
        self.addCleanup(move_to_thread_patcher.stop)
        move_to_thread_patcher.start()
        set_icon_patcher = patch(
            'openlp.core.ui.firsttimeform.ThemeListWidgetItem.setIcon')
        self.addCleanup(set_icon_patcher.stop)
        self.mocked_set_icon = set_icon_patcher.start()
        q_thread_patcher = patch('openlp.core.ui.firsttimeform.QtCore.QThread')
        self.addCleanup(q_thread_patcher.stop)
        q_thread_patcher.start()
Beispiel #5
0
def test_on_go_live_preview_controller():
    """
    Test that when the on_go_preview() method is called the message is sent to the preview controller and focus is
    set correctly.
    """
    # GIVEN: A new SlideController instance and plugin preview then pressing go live should respond
    mocked_display = MagicMock()
    mocked_preview_controller = MagicMock()
    mocked_preview_widget = MagicMock()
    mocked_service_item = MagicMock()
    mocked_service_item.from_service = False
    mocked_preview_widget.current_slide_number.return_value = 1
    mocked_preview_widget.slide_count = MagicMock(return_value=2)
    mocked_preview_controller.preview_widget = MagicMock()
    Registry.create()
    Registry().register('preview_controller', mocked_preview_controller)
    slide_controller = SlideController(None)
    slide_controller.service_item = mocked_service_item
    slide_controller.preview_widget = mocked_preview_widget
    slide_controller.displays = [mocked_display]

    # WHEN: on_go_live() is called
    slide_controller.on_go_preview()

    # THEN: the preview controller should have the service item and the focus set to live
    mocked_preview_controller.preview_widget.setFocus.assert_called_once_with()
Beispiel #6
0
    def test_on_go_live_service_manager(self):
        """
        Test that when the on_go_live() method is called the message is sent to the live controller and focus is
        set correctly.
        """
        # GIVEN: A new SlideController instance and service manager preview then pressing go live should respond
        mocked_display = MagicMock()
        mocked_service_manager = MagicMock()
        mocked_live_controller = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_service_item = MagicMock()
        mocked_service_item.from_service = True
        mocked_service_item.unique_identifier = 42
        mocked_preview_widget.current_slide_number.return_value = 1
        mocked_preview_widget.slide_count = MagicMock(return_value=2)
        mocked_live_controller.preview_widget = MagicMock()
        Registry.create()
        Registry().register('live_controller', mocked_live_controller)
        Registry().register('service_manager', mocked_service_manager)
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_service_item
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.display = mocked_display

        # WHEN: on_go_live() is called
        slide_controller.on_go_live()

        # THEN: the service manager should have the service item and the focus set to live
        mocked_service_manager.preview_live.assert_called_once_with(42, 1)
        mocked_live_controller.preview_widget.setFocus.assert_called_once_with()
Beispiel #7
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm'), \
             patch('openlp.core.ui.mainwindow.ImageManager'), \
             patch('openlp.core.ui.mainwindow.LiveController'), \
             patch('openlp.core.ui.mainwindow.PreviewController'), \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
             patch('openlp.core.ui.mainwindow.ServiceManager'), \
             patch('openlp.core.ui.mainwindow.ThemeManager'), \
             patch('openlp.core.ui.mainwindow.ProjectorManager'), \
             patch('openlp.core.ui.mainwindow.Renderer'), \
             patch('openlp.core.ui.mainwindow.websockets.WebSocketServer'), \
             patch('openlp.core.ui.mainwindow.server.HttpServer'):
         self.main_window = MainWindow()
Beispiel #8
0
 def setUp(self):
     """
     Set up the environment for testing bible queries with 1 Timothy 3
     """
     self.setup_application()
     self.build_settings()
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('application', MagicMock())
     bible_settings = {
         'bibles/proxy name': '',
         'bibles/db type': 'sqlite',
         'bibles/book name language': LanguageSelection.Bible,
         'bibles/verse separator': '',
         'bibles/range separator': '',
         'bibles/list separator': '',
         'bibles/end separator': '',
     }
     Settings().extend_default_settings(bible_settings)
     with patch('openlp.core.common.applocation.Settings') as mocked_class, \
             patch('openlp.core.common.applocation.AppLocation.get_section_data_path') as mocked_get_data_path, \
             patch('openlp.core.common.applocation.AppLocation.get_files') as mocked_get_files:
         # GIVEN: A mocked out Settings class and a mocked out AppLocation.get_files()
         mocked_settings = mocked_class.return_value
         mocked_settings.contains.return_value = False
         mocked_get_files.return_value = ["tests.sqlite"]
         mocked_get_data_path.return_value = TEST_RESOURCES_PATH + "/bibles"
         self.manager = BibleManager(MagicMock())
Beispiel #9
0
    def test_build_html_video(self, MockedSettings, Mocked_build_html):
        # GIVEN: Mocked display
        display = MagicMock()
        mocked_media_controller = MagicMock()
        Registry.create()
        Registry().register('media_controller', mocked_media_controller)
        main_display = MainDisplay(display)
        main_display.frame = MagicMock()
        mocked_settings = MagicMock()
        mocked_settings.value.return_value = False
        MockedSettings.return_value = mocked_settings
        main_display.shake_web_view = MagicMock()
        service_item = MagicMock()
        service_item.theme_data = MagicMock()
        service_item.theme_data.background_type = 'video'
        service_item.theme_data.theme_name = 'name'
        service_item.theme_data.background_filename = Path(
            'background_filename')
        mocked_plugin = MagicMock()
        display.plugin_manager = PluginManager()
        display.plugin_manager.plugins = [mocked_plugin]
        main_display.web_view = MagicMock()

        # WHEN: build_html is called with a normal service item and a video theme.
        main_display.build_html(service_item)

        # THEN: the following should had not been called
        assert main_display.web_view.setHtml.call_count == 1, 'setHTML should be called once'
        assert main_display.media_controller.video.call_count == 1, \
            'Media Controller video should have been called once'
Beispiel #10
0
 def setUp(self):
     """
     Patch and set up the mocks required.
     """
     Registry.create()
     self.add_copyright_patcher = patch(
         'openlp.plugins.songs.lib.importers.%s.%s.add_copyright' %
         (self.importer_module_name, self.importer_class_name))
     self.add_verse_patcher = patch(
         'openlp.plugins.songs.lib.importers.%s.%s.add_verse' %
         (self.importer_module_name, self.importer_class_name))
     self.finish_patcher = patch(
         'openlp.plugins.songs.lib.importers.%s.%s.finish' %
         (self.importer_module_name, self.importer_class_name))
     self.add_author_patcher = patch(
         'openlp.plugins.songs.lib.importers.%s.%s.add_author' %
         (self.importer_module_name, self.importer_class_name))
     self.song_import_patcher = patch(
         'openlp.plugins.songs.lib.importers.%s.SongImport' %
         self.importer_module_name)
     self.mocked_add_copyright = self.add_copyright_patcher.start()
     self.mocked_add_verse = self.add_verse_patcher.start()
     self.mocked_finish = self.finish_patcher.start()
     self.mocked_add_author = self.add_author_patcher.start()
     self.mocked_song_importer = self.song_import_patcher.start()
     self.mocked_manager = MagicMock()
     self.mocked_import_wizard = MagicMock()
     self.mocked_finish.return_value = True
Beispiel #11
0
    def setUp(self, mocked_init_url):
        """
        Set up anything necessary for all tests
        """
        self.tmp_folder = mkdtemp(prefix='openlp_')
        # Create a test app to keep from segfaulting
        Registry.create()
        self.registry = Registry()
        self.setup_application()
        # Mock cursor busy/normal methods.
        self.app.set_busy_cursor = MagicMock()
        self.app.set_normal_cursor = MagicMock()
        self.app.args = []
        Registry().register('application', self.app)
        Registry().set_flag('no_web_server', True)
        # Mock classes and methods used by mainwindow.
        with patch('openlp.core.ui.mainwindow.SettingsForm'), \
                patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
                patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
                patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
                patch('openlp.core.ui.mainwindow.ServiceManager'), \
                patch('openlp.core.ui.mainwindow.ThemeManager'), \
                patch('openlp.core.ui.mainwindow.ProjectorManager'), \
                patch('openlp.core.ui.mainwindow.WebSocketServer'), \
                patch('openlp.core.ui.mainwindow.HttpServer'), \
                patch('openlp.core.ui.mainwindow.start_zeroconf'), \
                patch('openlp.core.state.State.list_plugins') as mock_plugins:
            mock_plugins.return_value = []
            self.main_window = MainWindow()

        tmpdb_url = 'sqlite:///{db}'.format(
            db=os.path.join(self.tmp_folder, TEST_DB))
        mocked_init_url.return_value = tmpdb_url
        self.projector = ProjectorDB()
Beispiel #12
0
 def setUp(self):
     """
     Set up the objects we need for all of the tests
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.process_events = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     self.add_toolbar_action_patcher = patch(
         'openlp.core.ui.mainwindow.create_action')
     self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start(
     )
     self.mocked_add_toolbar_action.side_effect = self._create_mock_action
     self.renderer_patcher = patch('openlp.core.display.render.Renderer')
     self.mocked_renderer = self.renderer_patcher.start()
     mocked_desktop = MagicMock()
     mocked_desktop.screenCount.return_value = 1
     mocked_desktop.screenGeometry.return_value = QtCore.QRect(
         0, 0, 1024, 768)
     mocked_desktop.primaryScreen.return_value = 1
     ScreenList.create(mocked_desktop)
     State().load_settings()
     self.main_window = MainWindow()
Beispiel #13
0
 def setUp(self):
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \
             patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \
             patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \
             patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.mocked_settings_form = mocked_settings_form
         self.mocked_image_manager = mocked_image_manager
         self.mocked_live_controller = mocked_live_controller
         self.mocked_preview_controller = mocked_preview_controller
         self.mocked_dock_widget = mocked_dock_widget
         self.mocked_q_tool_box_class = mocked_q_tool_box_class
         self.mocked_add_dock_method = mocked_add_dock_method
         self.mocked_theme_manager = mocked_theme_manager
         self.mocked_renderer = mocked_renderer
         self.main_window = MainWindow()
Beispiel #14
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     mocked_plugin = MagicMock()
     mocked_plugin.status = PluginStatus.Active
     mocked_plugin.icon = QtGui.QIcon()
     Registry().register('mock_plugin', mocked_plugin)
     State().add_service("mock",
                         1,
                         is_plugin=True,
                         status=PluginStatus.Active)
     # Mock classes and methods used by mainwindow.
     with patch('openlp.core.ui.mainwindow.SettingsForm'), \
             patch('openlp.core.ui.mainwindow.OpenLPDockWidget'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox'), \
             patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget'), \
             patch('openlp.core.ui.mainwindow.ServiceManager'), \
             patch('openlp.core.ui.mainwindow.ThemeManager'), \
             patch('openlp.core.ui.mainwindow.ProjectorManager'), \
             patch('openlp.core.ui.mainwindow.HttpServer'), \
             patch('openlp.core.ui.mainwindow.WebSocketServer'), \
             patch('openlp.core.ui.mainwindow.start_zeroconf'), \
             patch('openlp.core.ui.mainwindow.PluginForm'):
         self.main_window = MainWindow()
Beispiel #15
0
 def setUp(self):
     """
     Set up the patches and mocks need for all tests.
     """
     self.setup_application()
     self.build_settings()
     self.mock_plugin = MagicMock()
     self.temp_folder = mkdtemp()
     self.mock_plugin.settings_section = self.temp_folder
     self.powerpoint_document_stop_presentation_patcher = patch(
         'openlp.plugins.presentations.lib.powerpointcontroller.PowerpointDocument.stop_presentation'
     )
     self.presentation_document_get_temp_folder_patcher = patch(
         'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument.get_temp_folder'
     )
     self.presentation_document_setup_patcher = patch(
         'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument._setup'
     )
     self.mock_powerpoint_document_stop_presentation = self.powerpoint_document_stop_presentation_patcher.start(
     )
     self.mock_presentation_document_get_temp_folder = self.presentation_document_get_temp_folder_patcher.start(
     )
     self.mock_presentation_document_setup = self.presentation_document_setup_patcher.start(
     )
     self.mock_controller = MagicMock()
     self.mock_presentation = MagicMock()
     self.mock_presentation_document_get_temp_folder.return_value = 'temp folder'
     self.file_name = os.path.join(TEST_RESOURCES_PATH, 'presentations',
                                   'test.pptx')
     self.real_controller = PowerpointController(self.mock_plugin)
     Settings().extend_default_settings(__default_settings__)
     Registry.create()
     Registry().register('settings', Settings())
Beispiel #16
0
 def setUp(self):
     """
     Set up the objects we need for all of the tests
     """
     Registry.create()
     self.registry = Registry()
     self.setup_application()
     # Mock cursor busy/normal methods.
     self.app.set_busy_cursor = MagicMock()
     self.app.set_normal_cursor = MagicMock()
     self.app.process_events = MagicMock()
     self.app.args = []
     Registry().register('application', self.app)
     Registry().set_flag('no_web_server', True)
     self.add_toolbar_action_patcher = patch(
         'openlp.core.ui.mainwindow.create_action')
     self.mocked_add_toolbar_action = self.add_toolbar_action_patcher.start(
     )
     self.mocked_add_toolbar_action.side_effect = self._create_mock_action
     with patch('openlp.core.display.screens.ScreenList.__instance__',
                spec=ScreenList) as mocked_screen_list:
         mocked_screen_list.current = {
             'number': 0,
             'size': QtCore.QSize(600, 800),
             'primary': True
         }
         self.main_window = MainWindow()
Beispiel #17
0
    def test_on_slide_selected_index_service_item_command(self, mocked_execute):
        """
        Test that when there is a command service item, the command is executed
        """
        # GIVEN: A mocked service item and a slide controller with a service item
        mocked_item = MagicMock()
        mocked_item.is_command.return_value = True
        mocked_item.name = 'Mocked Item'
        mocked_update_preview = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_slide_selected = MagicMock()
        Registry.create()
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_item
        slide_controller.update_preview = mocked_update_preview
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.slide_selected = mocked_slide_selected
        slide_controller.is_live = True

        # WHEN: The method is called
        slide_controller.on_slide_selected_index([9])

        # THEN: It should have sent a notification
        mocked_item.is_command.assert_called_once_with()
        mocked_execute.assert_called_once_with('mocked item_slide', [mocked_item, True, 9])
        mocked_update_preview.assert_called_once_with()
        assert 0 == mocked_preview_widget.change_slide.call_count, 'Change slide should not have been called'
        assert 0 == mocked_slide_selected.call_count, 'slide_selected should not have been called'
Beispiel #18
0
    def test_on_slide_selected_index_service_item_not_command(self, mocked_execute):
        """
        Test that when there is a service item but it's not a command, the preview widget is updated
        """
        # GIVEN: A mocked service item and a slide controller with a service item
        mocked_item = MagicMock()
        mocked_item.is_command.return_value = False
        mocked_item.name = 'Mocked Item'
        mocked_update_preview = MagicMock()
        mocked_preview_widget = MagicMock()
        mocked_slide_selected = MagicMock()
        Registry.create()
        slide_controller = SlideController(None)
        slide_controller.service_item = mocked_item
        slide_controller.update_preview = mocked_update_preview
        slide_controller.preview_widget = mocked_preview_widget
        slide_controller.slide_selected = mocked_slide_selected

        # WHEN: The method is called
        slide_controller.on_slide_selected_index([7])

        # THEN: It should have sent a notification
        mocked_item.is_command.assert_called_once_with()
        assert 0 == mocked_execute.call_count, 'Execute should not have been called'
        assert 0 == mocked_update_preview.call_count, 'Update preview should not have been called'
        mocked_preview_widget.change_slide.assert_called_once_with(7)
        mocked_slide_selected.assert_called_once_with()
Beispiel #19
0
 def setUp(self):
     """
     Create the UI
     """
     self.registry = Registry()
     Registry.create()
     self.setup_application()
     self.build_settings()
     State().load_settings()
     Registry().register('settings', Settings())
     Registry().register(
         'main_window',
         MagicMock(service_manager_settings_section='servicemanager'))
     self.application_id = 'abc'
     self.secret = '123'
     Settings().setValue('planningcenter/application_id',
                         self.application_id)
     Settings().setValue('planningcenter/secret', self.secret)
     # init the planning center plugin so we have default values defined for Settings()
     self.planning_center_plugin = PlanningCenterPlugin()
     # setup our form
     self.form = SelectPlanForm()
     self.form.planning_center_api.airplane_mode = True
     self.form.planning_center_api.airplane_mode_directory = TEST_PATH
     self.theme_manager = ThemeManager(None)
     self.theme_manager.get_theme_names = MagicMock()
     self.theme_manager.get_theme_names.return_value = ['themeA', 'themeB']
Beispiel #20
0
 def setUp(self):
     """
     Create the registry
     """
     self.setup_application()
     Registry.create()
     self.build_settings()
Beispiel #21
0
    def setUp(self):
        """
        Setup for tests
        """
        Registry.create()
        self.registry = Registry()
        self.mocked_live_controller = MagicMock()
        self.desktop = MagicMock()
        self.desktop.primaryScreen.return_value = SCREEN['primary']
        self.desktop.screenCount.return_value = SCREEN['number']
        self.desktop.screenGeometry.return_value = SCREEN['size']
        with patch('openlp.core.display.screens.QtWidgets.QApplication.screens') as mocked_screens:
            mocked_screens.return_value = [
                MagicMock(**{'geometry.return_value': SCREEN['size']})
            ]
            self.screens = ScreenList.create(self.desktop)
        # Mock the renderer and its format_slide method
        self.mocked_renderer = MagicMock()

        def side_effect_return_arg(arg1, arg2):
            return [arg1]
        self.mocked_slide_formater = MagicMock(side_effect=side_effect_return_arg)
        self.mocked_renderer.format_slide = self.mocked_slide_formater
        Registry().register('live_controller', self.mocked_live_controller)
        Registry().register('renderer', self.mocked_renderer)
        Registry().register('settings', MagicMock(**{'value.return_value': 'english'}))
Beispiel #22
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     mocked_renderer = MagicMock()
     Registry().register('renderer', mocked_renderer)
Beispiel #23
0
 def setUp(self):
     """
     Set up the components need for all tests.
     """
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('main_window', MagicMock())
     self.mocked_plugin = MagicMock()
     with patch('openlp.core.lib.mediamanageritem.MediaManagerItem._setup'), \
             patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__'):
         self.media_item = SongMediaItem(None, self.mocked_plugin)
         self.media_item.save_auto_select_id = MagicMock()
         self.media_item.list_view = MagicMock()
         self.media_item.list_view.save_auto_select_id = MagicMock()
         self.media_item.list_view.clear = MagicMock()
         self.media_item.list_view.addItem = MagicMock()
         self.media_item.list_view.setCurrentItem = MagicMock()
         self.media_item.auto_select_id = -1
         self.media_item.display_songbook = False
         self.media_item.display_copyright_symbol = False
     self.setup_application()
     self.build_settings()
     Settings().extend_default_settings(__default_settings__)
     self.settings = self.setting
     Registry().register('settings', self.settings)
     QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
Beispiel #24
0
 def __init__(self, *args, **kwargs):
     super(SongImportTestHelper, self).__init__(*args, **kwargs)
     self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' %
                                       self.importer_module_name, fromlist=[self.importer_class_name])
     self.importer_class = getattr(self.importer_module, self.importer_class_name)
     Registry.create()
     Registry().register('settings', MagicMock())
     self.settings = Registry().get('settings')
Beispiel #25
0
 def setUp(self):
     """
     Create the UI and setup necessary options
     """
     self.setup_application()
     self.build_settings()
     Registry.create()
     """
Beispiel #26
0
 def setUp(self):
     """
     Create the UI
     """
     self.setup_application()
     self.build_settings()
     Registry.create()
     self.theme_manager = ThemeManager()
Beispiel #27
0
 def setUp(self):
     """
     Set up the Registry
     """
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('application', MagicMock())
     Registry().register('main_window', MagicMock())
Beispiel #28
0
 def setUp(self):
     self.setup_application()
     self.app.setApplicationVersion('0.0')
     # Set up a fake "set_normal_cursor" method since we're not dealing with an actual OpenLP application object
     self.app.set_normal_cursor = lambda: None
     self.app.process_events = lambda: None
     Registry.create()
     Registry().register('application', self.app)
     self.tempfile = os.path.join(tempfile.gettempdir(), 'testfile')
Beispiel #29
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = EditCustomSlideForm()
Beispiel #30
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = ChooseGroupForm(self.main_window)
Beispiel #31
0
 def setUp(self):
     """
     Some pre-test setup required.
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.combo = HistoryComboBox(self.main_window)
Beispiel #32
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()