当前位置: 首页>>代码示例>>Python>>正文


Python Registry.create方法代码示例

本文整理汇总了Python中openlp.core.common.Registry.create方法的典型用法代码示例。如果您正苦于以下问题:Python Registry.create方法的具体用法?Python Registry.create怎么用?Python Registry.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在openlp.core.common.Registry的用法示例。


在下文中一共展示了Registry.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 def setUp(self):
     """
     Create the registry
     """
     self.setup_application()
     Registry.create()
     self.build_settings()
开发者ID:imkernel,项目名称:openlp,代码行数:9,代码来源:test_openlyricsimport.py

示例2: test_registry_function

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
    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')
开发者ID:imkernel,项目名称:openlp,代码行数:29,代码来源:test_registry.py

示例3: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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")
开发者ID:crossroadchurch,项目名称:paul,代码行数:30,代码来源:test_servicemanager.py

示例4: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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()
开发者ID:crossroadchurch,项目名称:paul,代码行数:27,代码来源:test_mainwindow.py

示例5: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 def setUp(self):
     """
     Set up the Registry
     """
     Registry.create()
     Registry().register('service_list', MagicMock())
     Registry().register('application', MagicMock())
开发者ID:crossroadchurch,项目名称:paul,代码行数:9,代码来源:test_lib_http.py

示例6: test_registry_service

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
    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')
开发者ID:imkernel,项目名称:openlp,代码行数:33,代码来源:test_registry.py

示例7: test_build_html_video

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
    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')
开发者ID:imkernel,项目名称:openlp,代码行数:31,代码来源:test_maindisplay.py

示例8: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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())
开发者ID:crossroadchurch,项目名称:paul,代码行数:29,代码来源:test_lib_parse_reference.py

示例9: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 def setUp(self):
     """
     Create the UI
     """
     self.build_settings()
     self.setup_application()
     Registry.create()
     self.theme_manager = ThemeManager()
开发者ID:crossroadchurch,项目名称:paul,代码行数:10,代码来源:test_thememanager.py

示例10: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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()
开发者ID:crossroadchurch,项目名称:paul,代码行数:11,代码来源:test_customslideform.py

示例11: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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()
开发者ID:crossroadchurch,项目名称:paul,代码行数:11,代码来源:test_servicenotedialog.py

示例12: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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)
开发者ID:crossroadchurch,项目名称:paul,代码行数:11,代码来源:test_historycombobox.py

示例13: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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()
开发者ID:imkernel,项目名称:openlp,代码行数:11,代码来源:test_authorsform.py

示例14: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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()
开发者ID:crossroadchurch,项目名称:paul,代码行数:11,代码来源:test_topicsform.py

示例15: setUp

# 需要导入模块: from openlp.core.common import Registry [as 别名]
# 或者: from openlp.core.common.Registry import create [as 别名]
 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')
开发者ID:imkernel,项目名称:openlp,代码行数:11,代码来源:test_exceptionform.py


注:本文中的openlp.core.common.Registry.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。