本文整理汇总了Python中openlp.core.common.Registry类的典型用法代码示例。如果您正苦于以下问题:Python Registry类的具体用法?Python Registry怎么用?Python Registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
"""
Create the registry
"""
self.setup_application()
Registry.create()
self.build_settings()
示例2: test_registry_function
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')
示例3: setUp
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")
示例4: setUp
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()
示例5: setUp
def setUp(self):
"""
Set up the Registry
"""
Registry.create()
Registry().register('service_list', MagicMock())
Registry().register('application', MagicMock())
示例6: test_registry_service
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')
示例7: test_build_html_video
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')
示例8: setUp
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())
示例9: setUp
def setUp(self):
"""
Create the UI
"""
self.build_settings()
self.setup_application()
Registry.create()
self.theme_manager = ThemeManager()
示例10: setUp
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()
示例11: setUp
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()
示例12: setUp
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)
示例13: setUp
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()
示例14: setUp
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()
示例15: setUp
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')