コード例 #1
0
ファイル: test_maindisplay.py プロジェクト: imkernel/openlp
    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 = '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
        self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once')
        self.assertEquals(main_display.media_controller.video.call_count, 1,
                          'Media Controller video should have been called once')
コード例 #2
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'
        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
        self.assertEquals(main_display.web_view.setHtml.call_count, 1,
                          'setHTML should be called once')
        self.assertEquals(
            main_display.media_controller.video.call_count, 1,
            'Media Controller video should have been called once')
コード例 #3
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)
     # 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.QtGui.QToolBox') as mocked_q_tool_box_class, \
             patch('openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget') as mocked_add_dock_method, \
             patch('openlp.core.ui.mainwindow.ServiceManager') as mocked_service_manager, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.main_window = MainWindow()
コード例 #4
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)
     # 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.ServiceManager') as mocked_service_manager, \
             patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \
             patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \
             patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer:
         self.main_window = MainWindow()
コード例 #5
0
 def setUp(self):
     """
     Set up the environment for testing bible parse reference
     """
     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.get_section_data_path') as mocked_get_section_data_path, \
             patch('openlp.core.common.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_section_data_path.return_value = TEST_RESOURCES_PATH + "/bibles"
         self.manager = BibleManager(MagicMock())
コード例 #6
0
 def setUp(self):
     """
     Create the registry
     """
     self.setup_application()
     Registry.create()
     self.build_settings()
コード例 #7
0
 def setUp(self):
     """
     Set up the environment for testing bible parse reference
     """
     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.get_section_data_path') as mocked_get_section_data_path, \
             patch('openlp.core.common.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_section_data_path.return_value = TEST_RESOURCES_PATH + "/bibles"
         self.manager = BibleManager(MagicMock())
コード例 #8
0
ファイル: test_openlyricsimport.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Create the registry
     """
     self.setup_application()
     Registry.create()
     self.build_settings()
コード例 #9
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
        self.assertEqual(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
        self.assertEqual(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
        self.assertEqual(return_value[0], 'function_2',
                         'A return value is provided and matches')
コード例 #10
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     ScreenList.create(self.app.desktop())
     Registry().register("application", MagicMock())
     # 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.QtGui.QToolBox"
     ) as mocked_q_tool_box_class, patch(
         "openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget"
     ) as mocked_add_dock_method, patch(
         "openlp.core.ui.mainwindow.ThemeManager"
     ) as mocked_theme_manager, patch(
         "openlp.core.ui.mainwindow.ProjectorManager"
     ) as mocked_projector_manager, patch(
         "openlp.core.ui.mainwindow.Renderer"
     ) as mocked_renderer:
         self.main_window = MainWindow()
     self.service_manager = Registry().get("service_manager")
コード例 #11
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
コード例 #12
0
ファイル: test_lib_http.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Set up the Registry
     """
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('application', MagicMock())
コード例 #13
0
ファイル: test_registry.py プロジェクト: imkernel/openlp
    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
        self.assertEqual(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
        self.assertEqual(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
        self.assertEqual(return_value[0], 'function_2', 'A return value is provided and matches')
コード例 #14
0
ファイル: test_registry.py プロジェクト: imkernel/openlp
    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)
        self.assertEqual(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')
        self.assertEqual(temp, 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')
        self.assertEqual(temp, None, 'None should have been returned for deleted service')
コード例 #15
0
ファイル: test_thememanager.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Create the UI
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     self.theme_manager = ThemeManager()
コード例 #16
0
ファイル: test_servicenotedialog.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = servicenoteform.ServiceNoteForm()
コード例 #17
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register("main_window", self.main_window)
     self.form = EditCustomSlideForm()
コード例 #18
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 = starttimeform.StartTimeForm()
コード例 #19
0
ファイル: test_authorsform.py プロジェクト: imkernel/openlp
 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 = AuthorsForm()
コード例 #20
0
 def setUp(self):
     """
     Set up the Registry
     """
     Registry.create()
     mocked_renderer = MagicMock()
     mocked_renderer.format_slide.return_value = [VERSE]
     Registry().register('renderer', mocked_renderer)
     Registry().register('image_manager', MagicMock())
コード例 #21
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = TopicsForm()
コード例 #22
0
ファイル: test_historycombobox.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Some pre-test setup required.
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.combo = HistoryComboBox(self.main_window)
コード例 #23
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = filerenameform.FileRenameForm()
コード例 #24
0
ファイル: test_customslideform.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     self.form = EditCustomSlideForm()
コード例 #25
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 = ShortcutListForm()
コード例 #26
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')
コード例 #27
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register("main_window", self.main_window)
     self.form = ShortcutListForm()
コード例 #28
0
ファイル: test_exceptionform.py プロジェクト: imkernel/openlp
 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')
コード例 #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)
     bibleimportform.PYSWORD_AVAILABLE = False
     self.form = bibleimportform.BibleImportForm(self.main_window, MagicMock(), MagicMock())
コード例 #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)
     Registry().register('theme_manager', MagicMock())
     self.form = EditSongForm(MagicMock(), self.main_window, MagicMock())
コード例 #31
0
ファイル: test_image_manager.py プロジェクト: jkunle/paul
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     ScreenList.create(self.app.desktop())
     self.image_manager = ImageManager()
     self.lock = Lock()
     self.sleep_time = 0.1
コード例 #32
0
 def setUp(self):
     """
     Set up the components need for all tests.
     """
     Registry.create()
     Registry().register('service_manager', MagicMock())
     Registry().register('main_window', MagicMock())
     with patch('openlp.plugins.presentations.lib.mediaitem.MediaManagerItem._setup'), \
             patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.setup_item'):
         self.media_item = PresentationMediaItem(None, MagicMock, MagicMock())
コード例 #33
0
ファイル: test_router.py プロジェクト: crossroadchurch/paul
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.build_settings()
     Settings().extend_default_settings(__default_settings__)
     self.service_manager = ServiceManager()
     self.router = HttpRouter()
コード例 #34
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.build_settings()
     Settings().extend_default_settings(__default_settings__)
     self.service_manager = ServiceManager()
     self.router = HttpRouter()
コード例 #35
0
ファイル: test_editsongform.py プロジェクト: imkernel/openlp
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     Registry().register('theme_manager', MagicMock())
     self.form = EditSongForm(MagicMock(), self.main_window, MagicMock())
コード例 #36
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtGui.QMainWindow()
     Registry().register('main_window', self.main_window)
     media_item = MagicMock()
     manager = MagicMock()
     self.form = EditCustomForm(media_item, self.main_window, manager)
コード例 #37
0
 def setUp(self):
     """
     Set up the components need for all tests.
     """
     with patch('openlp.plugins.bibles.lib.mediaitem.MediaManagerItem._setup'),\
             patch('openlp.plugins.bibles.lib.mediaitem.BibleMediaItem.setup_item'):
         self.media_item = BibleMediaItem(None, MagicMock())
     self.setup_application()
     self.mocked_main_window = MagicMock()
     Registry.create()
     Registry().register('main_window', self.mocked_main_window)
コード例 #38
0
 def setUp(self):
     """
     Set up the components need for all tests.
     """
     Registry.create()
     Registry().register('service_manager', MagicMock())
     Registry().register('main_window', MagicMock())
     with patch('openlp.plugins.presentations.lib.mediaitem.MediaManagerItem._setup'), \
             patch('openlp.plugins.presentations.lib.mediaitem.PresentationMediaItem.setup_item'):
         self.media_item = PresentationMediaItem(None, MagicMock,
                                                 MagicMock())
コード例 #39
0
ファイル: test_renderer.py プロジェクト: crossroadchurch/paul
 def setUp(self):
     """
     Set up the components need for all tests
     """
     # Mocked out desktop object
     self.desktop = MagicMock()
     self.desktop.primaryScreen.return_value = SCREEN['primary']
     self.desktop.screenCount.return_value = SCREEN['number']
     self.desktop.screenGeometry.return_value = SCREEN['size']
     self.screens = ScreenList.create(self.desktop)
     Registry.create()
コード例 #40
0
ファイル: test_customform.py プロジェクト: imkernel/openlp
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     media_item = MagicMock()
     manager = MagicMock()
     self.form = EditCustomForm(media_item, self.main_window, manager)
コード例 #41
0
ファイル: test_renderer.py プロジェクト: feitianyiren/openlp
 def setUp(self):
     """
     Set up the components need for all tests
     """
     # Mocked out desktop object
     self.desktop = MagicMock()
     self.desktop.primaryScreen.return_value = SCREEN['primary']
     self.desktop.screenCount.return_value = SCREEN['number']
     self.desktop.screenGeometry.return_value = SCREEN['size']
     self.screens = ScreenList.create(self.desktop)
     Registry.create()
コード例 #42
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
     bibleimportform.PYSWORD_AVAILABLE = False
     self.form = bibleimportform.BibleImportForm(self.main_window,
                                                 MagicMock(), MagicMock())
コード例 #43
0
 def setUp(self):
     """
     Some pre-test setup required.
     """
     self.setup_application()
     self.build_settings()
     self.temp_dir = mkdtemp('openlp')
     Settings().setValue('advanced/data path', self.temp_dir)
     Registry.create()
     Registry().register('service_list', MagicMock())
     self.main_window = QtWidgets.QMainWindow()
     Registry().register('main_window', self.main_window)
コード例 #44
0
ファイル: test_registrymixin.py プロジェクト: imkernel/openlp
    def test_registry_mixin_present(self):
        """
        Test the registry creation and its usage
        """
        # GIVEN: A new registry
        Registry.create()

        # WHEN: I create a new class
        mock_2 = Test2()

        # THEN: The following bootstrap methods should be present
        self.assertEqual(len(Registry().functions_list), 2), 'The bootstrap functions should be in the dict.'
コード例 #45
0
ファイル: test_editsongform.py プロジェクト: imkernel/openlp
 def setUp(self):
     """
     Set up the components need for all tests.
     """
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('main_window', MagicMock())
     with patch('openlp.plugins.songs.forms.editsongform.EditSongForm.__init__', return_value=None):
         self.edit_song_form = EditSongForm(None, MagicMock(), MagicMock())
     self.setup_application()
     self.build_settings()
     QtCore.QLocale.setDefault(QtCore.QLocale('en_GB'))
コード例 #46
0
ファイル: test_searchedit.py プロジェクト: jkunle/paul
    def setUp(self):
        """
        Create the UI
        """
        Registry.create()
        self.setup_application()
        self.main_window = QtGui.QMainWindow()
        Registry().register('main_window', self.main_window)

        self.search_edit = SearchEdit(self.main_window)
        # To complete set up we have to set the search types.
        self.search_edit.set_search_types(SEARCH_TYPES)
コード例 #47
0
ファイル: test_imagetab.py プロジェクト: imkernel/openlp
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     Registry().register('settings_form', MagicMock())
     self.setup_application()
     self.build_settings()
     Settings().extend_default_settings(__default_settings__)
     self.parent = QtWidgets.QMainWindow()
     self.form = ImageTab(self.parent, 'Images', None, None)
     self.form.settings_form.register_post_process = MagicMock()
コード例 #48
0
ファイル: test_lib.py プロジェクト: jkunle/paul
 def setUp(self):
     self.mocked_main_window = MagicMock()
     Registry.create()
     Registry().register('application', MagicMock())
     Registry().register('service_list', MagicMock())
     Registry().register('main_window', self.mocked_main_window)
     Registry().register('live_controller', MagicMock())
     mocked_plugin = MagicMock()
     with patch('openlp.plugins.images.lib.mediaitem.MediaManagerItem._setup'), \
             patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.setup_item'):
         self.media_item = ImageMediaItem(None, mocked_plugin)
         self.media_item.settings_section = 'images'
コード例 #49
0
ファイル: test_imagetab.py プロジェクト: feitianyiren/openlp
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     Registry().register('settings_form', MagicMock())
     self.setup_application()
     self.build_settings()
     Settings().extend_default_settings(__default_settings__)
     self.parent = QtWidgets.QMainWindow()
     self.form = ImageTab(self.parent, 'Images', None, None)
     self.form.settings_form.register_post_process = MagicMock()
コード例 #50
0
ファイル: test_lib.py プロジェクト: imkernel/openlp
 def setUp(self):
     self.mocked_main_window = MagicMock()
     Registry.create()
     Registry().register('application', MagicMock())
     Registry().register('service_list', MagicMock())
     Registry().register('main_window', self.mocked_main_window)
     Registry().register('live_controller', MagicMock())
     mocked_plugin = MagicMock()
     with patch('openlp.plugins.images.lib.mediaitem.MediaManagerItem._setup'), \
             patch('openlp.plugins.images.lib.mediaitem.ImageMediaItem.setup_item'):
         self.media_item = ImageMediaItem(None, mocked_plugin)
         self.media_item.settings_section = 'images'
コード例 #51
0
 def setUp(self):
     """
     Create the UI.
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32)
     self.image_manager = MagicMock()
     self.image_manager.get_image.return_value = self.image
     Registry().register('image_manager', self.image_manager)
     self.preview_widget = ListPreviewWidget(self.main_window, 2)
コード例 #52
0
 def setUp(self):
     """
     Create the UI.
     """
     Registry.create()
     self.setup_application()
     self.main_window = QtWidgets.QMainWindow()
     self.image = QtGui.QImage(1, 1, QtGui.QImage.Format_RGB32)
     self.image_manager = MagicMock()
     self.image_manager.get_image.return_value = self.image
     Registry().register('image_manager', self.image_manager)
     self.preview_widget = ListPreviewWidget(self.main_window, 2)
コード例 #53
0
ファイル: test_registrymixin.py プロジェクト: jkunle/paul
    def registry_mixin_present_test(self):
        """
        Test the registry creation and its usage
        """
        # GIVEN: A new registry
        Registry.create()

        # WHEN: I create a new class
        mock_2 = Test2()

        # THEN: The following bootstrap methods should be present
        self.assertEqual(len(Registry().functions_list),
                         2), 'The bootstrap functions should be in the dict.'