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


Python ServiceItem.add_capability方法代码示例

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


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

示例1: test_add_from_command_for_a_presentation_thumb

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
    def test_add_from_command_for_a_presentation_thumb(self, mocked_get_section_data_path, mocked_image_manager):
        """
        Test the Service Item - adding a presentation, updating the thumb path & adding the thumb to image_manager
        """
        # GIVEN: A service item, a mocked AppLocation and presentation data
        mocked_get_section_data_path.return_value = os.path.join('mocked', 'section', 'path')
        service_item = ServiceItem(None)
        service_item.add_capability(ItemCapabilities.HasThumbnails)
        service_item.has_original_files = False
        service_item.name = 'presentations'
        presentation_name = 'test.pptx'
        thumb = os.path.join('tmp', 'test', 'thumb.png')
        display_title = 'DisplayTitle'
        notes = 'Note1\nNote2\n'
        expected_thumb_path = os.path.join('mocked', 'section', 'path', 'thumbnails',
                                           md5_hash(os.path.join(TEST_PATH, presentation_name).encode('utf-8')),
                                           'thumb.png')
        frame = {'title': presentation_name, 'image': expected_thumb_path, 'path': TEST_PATH,
                 'display_title': display_title, 'notes': notes}

        # WHEN: adding presentation to service_item
        service_item.add_from_command(TEST_PATH, presentation_name, thumb, display_title, notes)

        # THEN: verify that it is setup as a Command and that the frame data matches
        self.assertEqual(service_item.service_item_type, ServiceItemType.Command, 'It should be a Command')
        self.assertEqual(service_item.get_frames()[0], frame, 'Frames should match')
        self.assertEqual(1, mocked_image_manager.add_image.call_count, 'image_manager should be used')
开发者ID:imkernel,项目名称:openlp,代码行数:29,代码来源:test_serviceitem.py

示例2: auto_start_context_menu_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
    def auto_start_context_menu_test(self):
        """
        Test the context_menu() method with can auto start
        """
        # GIVEN: A service item added
        self.service_manager.setup_ui(self.service_manager)
        with patch("PyQt4.QtGui.QTreeWidget.itemAt") as mocked_item_at_method, patch(
            "PyQt4.QtGui.QWidget.mapToGlobal"
        ), patch("PyQt4.QtGui.QMenu.exec_"):
            mocked_item = MagicMock()
            mocked_item.parent.return_value = None
            mocked_item_at_method.return_value = mocked_item
            # We want 1 to be returned for the position
            mocked_item.data.return_value = 1
            # A service item without capabilities.
            service_item = ServiceItem()
            service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
            self.service_manager.service_items = [{"service_item": service_item}]
            q_point = None
            # Mocked actions.
            self.service_manager.edit_action.setVisible = MagicMock()
            self.service_manager.create_custom_action.setVisible = MagicMock()
            self.service_manager.maintain_action.setVisible = MagicMock()
            self.service_manager.notes_action.setVisible = MagicMock()
            self.service_manager.time_action.setVisible = MagicMock()
            self.service_manager.auto_start_action.setVisible = MagicMock()
            self.service_manager.rename_action.setVisible = MagicMock()

            # WHEN: Show the context menu.
            self.service_manager.context_menu(q_point)

            # THEN: The following actions should be not visible.
            self.service_manager.edit_action.setVisible.assert_called_once_with(
                False
            ), "The action should be set invisible."
            self.service_manager.create_custom_action.setVisible.assert_called_once_with(
                False
            ), "The action should be set invisible."
            self.service_manager.maintain_action.setVisible.assert_called_once_with(
                False
            ), "The action should be set invisible."
            self.service_manager.notes_action.setVisible.assert_called_with(True), "The action should be set visible."
            self.service_manager.time_action.setVisible.assert_called_once_with(
                False
            ), "The action should be set invisible."
            self.service_manager.auto_start_action.setVisible.assert_called_with(
                True
            ), "The action should be set visible."
            self.service_manager.rename_action.setVisible.assert_called_once_with(
                False
            ), "The action should be set invisible."
开发者ID:crossroadchurch,项目名称:paul,代码行数:53,代码来源:test_servicemanager.py

示例3: build_presentation_non_pdf_context_menu_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
 def build_presentation_non_pdf_context_menu_test(self):
     """
     Test the creation of a context menu from service item of type Command with Impress from Presentation.
     """
     # GIVEN: A new service manager instance and a default service item.
     Registry().register('plugin_manager', MagicMock())
     Registry().register('renderer', MagicMock())
     service_manager = ServiceManager(None)
     item = MagicMock()
     item.parent.return_value = False
     item.data.return_value = 0
     service_manager.service_manager_list = MagicMock()
     service_manager.service_manager_list.itemAt.return_value = item
     service_item = ServiceItem(None)
     service_item.add_capability(ItemCapabilities.ProvidesOwnDisplay)
     service_item.service_item_type = ServiceItemType.Command
     service_item.edit_id = 1
     service_item._raw_frames.append(MagicMock())
     service_manager.service_items.insert(1, {'service_item': service_item})
     service_manager.edit_action = MagicMock()
     service_manager.rename_action = MagicMock()
     service_manager.create_custom_action = MagicMock()
     service_manager.maintain_action = MagicMock()
     service_manager.notes_action = MagicMock()
     service_manager.time_action = MagicMock()
     service_manager.auto_start_action = MagicMock()
     service_manager.auto_play_slides_menu = MagicMock()
     service_manager.auto_play_slides_once = MagicMock()
     service_manager.auto_play_slides_loop = MagicMock()
     service_manager.timed_slide_interval = MagicMock()
     service_manager.theme_menu = MagicMock()
     service_manager.menu = MagicMock()
     # WHEN I define a context menu
     service_manager.context_menu(1)
     # THEN the following calls should have occurred.
     self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
                       'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
                       'Should have be called once')
开发者ID:crossroadchurch,项目名称:paul,代码行数:51,代码来源:test_servicemanager.py

示例4: test_loopy_context_menu

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
    def test_loopy_context_menu(self):
        """
        Test the context_menu() method with a loop
        """
        # GIVEN: A service item added
        self.service_manager.setup_ui(self.service_manager)
        with patch('PyQt5.QtWidgets.QTreeWidget.itemAt') as mocked_item_at_method, \
                patch('PyQt5.QtWidgets.QWidget.mapToGlobal'), \
                patch('PyQt5.QtWidgets.QMenu.exec'):
            mocked_item = MagicMock()
            mocked_item.parent.return_value = None
            mocked_item_at_method.return_value = mocked_item
            # We want 1 to be returned for the position
            mocked_item.data.return_value = 1
            # A service item without capabilities.
            service_item = ServiceItem()
            service_item.add_capability(ItemCapabilities.CanLoop)
            service_item._raw_frames.append("One")
            service_item._raw_frames.append("Two")
            self.service_manager.service_items = [{'service_item': service_item}]
            q_point = None
            # Mocked actions.
            self.service_manager.edit_action.setVisible = MagicMock()
            self.service_manager.create_custom_action.setVisible = MagicMock()
            self.service_manager.maintain_action.setVisible = MagicMock()
            self.service_manager.notes_action.setVisible = MagicMock()
            self.service_manager.time_action.setVisible = MagicMock()
            self.service_manager.auto_start_action.setVisible = MagicMock()

            # WHEN: Show the context menu.
            self.service_manager.context_menu(q_point)

            # THEN: The following actions should be not visible.
            self.service_manager.edit_action.setVisible.assert_called_once_with(False), \
                'The action should be set invisible.'
            self.service_manager.create_custom_action.setVisible.assert_called_once_with(False), \
                'The action should be set invisible.'
            self.service_manager.maintain_action.setVisible.assert_called_once_with(False), \
                'The action should be set invisible.'
            self.service_manager.notes_action.setVisible.assert_called_with(True), 'The action should be set visible.'
            self.service_manager.time_action.setVisible.assert_called_once_with(False), \
                'The action should be set invisible.'
            self.service_manager.auto_start_action.setVisible.assert_called_once_with(False), \
                'The action should be set invisible.'
开发者ID:imkernel,项目名称:openlp,代码行数:46,代码来源:test_servicemanager.py

示例5: build_media_context_menu_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
 def build_media_context_menu_test(self):
     """
     Test the creation of a context menu from service item of type Command from Media.
     """
     # GIVEN: A new service manager instance and a default service item.
     Registry().register('plugin_manager', MagicMock())
     Registry().register('renderer', MagicMock())
     service_manager = ServiceManager(None)
     item = MagicMock()
     item.parent.return_value = False
     item.data.return_value = 0
     service_manager.service_manager_list = MagicMock()
     service_manager.service_manager_list.itemAt.return_value = item
     service_item = ServiceItem(None)
     service_item.add_capability(ItemCapabilities.CanAutoStartForLive)
     service_item.add_capability(ItemCapabilities.CanEditTitle)
     service_item.add_capability(ItemCapabilities.RequiresMedia)
     service_item.service_item_type = ServiceItemType.Command
     service_item.edit_id = 1
     service_item._raw_frames.append(MagicMock())
     service_manager.service_items.insert(1, {'service_item': service_item})
     service_manager.edit_action = MagicMock()
     service_manager.rename_action = MagicMock()
     service_manager.create_custom_action = MagicMock()
     service_manager.maintain_action = MagicMock()
     service_manager.notes_action = MagicMock()
     service_manager.time_action = MagicMock()
     service_manager.auto_start_action = MagicMock()
     service_manager.auto_play_slides_menu = MagicMock()
     service_manager.auto_play_slides_once = MagicMock()
     service_manager.auto_play_slides_loop = MagicMock()
     service_manager.timed_slide_interval = MagicMock()
     service_manager.theme_menu = MagicMock()
     service_manager.menu = MagicMock()
     # WHEN I define a context menu
     service_manager.context_menu(1)
     # THEN the following calls should have occurred.
     self.assertEquals(service_manager.edit_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.rename_action.setVisible.call_count, 2, 'Should have be called twice')
     self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 2, 'Should have be called twice')
     self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
                       'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 1,
                       'Should have be called once')
     # THEN I change the length of the media and regenerate the menu.
     service_item.set_media_length(5)
     service_manager.context_menu(1)
     # THEN the following additional calls should have occurred.
     self.assertEquals(service_manager.time_action.setVisible.call_count, 3, 'Should have be called three times')
开发者ID:crossroadchurch,项目名称:paul,代码行数:58,代码来源:test_servicemanager.py

示例6: build_custom_context_menu_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import add_capability [as 别名]
 def build_custom_context_menu_test(self):
     """
     Test the creation of a context menu from service item of type text from Custom.
     """
     # GIVEN: A new service manager instance and a default service item.
     mocked_renderer = MagicMock()
     mocked_renderer.theme_level = ThemeLevel.Song
     Registry().register('plugin_manager', MagicMock())
     Registry().register('renderer', mocked_renderer)
     service_manager = ServiceManager(None)
     item = MagicMock()
     item.parent.return_value = False
     item.data.return_value = 0
     service_manager.service_manager_list = MagicMock()
     service_manager.service_manager_list.itemAt.return_value = item
     service_item = ServiceItem(None)
     service_item.add_capability(ItemCapabilities.CanEdit)
     service_item.add_capability(ItemCapabilities.CanPreview)
     service_item.add_capability(ItemCapabilities.CanLoop)
     service_item.add_capability(ItemCapabilities.CanSoftBreak)
     service_item.add_capability(ItemCapabilities.OnLoadUpdate)
     service_item.service_item_type = ServiceItemType.Text
     service_item.edit_id = 1
     service_item._display_frames.append(MagicMock())
     service_manager.service_items.insert(1, {'service_item': service_item})
     service_manager.edit_action = MagicMock()
     service_manager.rename_action = MagicMock()
     service_manager.create_custom_action = MagicMock()
     service_manager.maintain_action = MagicMock()
     service_manager.notes_action = MagicMock()
     service_manager.time_action = MagicMock()
     service_manager.auto_start_action = MagicMock()
     service_manager.auto_play_slides_menu = MagicMock()
     service_manager.auto_play_slides_once = MagicMock()
     service_manager.auto_play_slides_loop = MagicMock()
     service_manager.timed_slide_interval = MagicMock()
     service_manager.theme_menu = MagicMock()
     service_manager.menu = MagicMock()
     # WHEN I define a context menu
     service_manager.context_menu(1)
     # THEN the following calls should have occurred.
     self.assertEquals(service_manager.edit_action.setVisible.call_count, 2, 'Should have be called twice')
     self.assertEquals(service_manager.rename_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.create_custom_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.maintain_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.notes_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.time_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_start_action.setVisible.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 1,
                       'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 0, 'Should not be called')
     self.assertEquals(service_manager.theme_menu.menuAction().setVisible.call_count, 2,
                       'Should have be called twice')
     # THEN we add a 2nd display frame
     service_item._display_frames.append(MagicMock())
     service_manager.context_menu(1)
     # THEN the following additional calls should have occurred.
     self.assertEquals(service_manager.auto_play_slides_menu.menuAction().setVisible.call_count, 2,
                       'Should have be called twice')
     self.assertEquals(service_manager.auto_play_slides_once.setChecked.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.auto_play_slides_loop.setChecked.call_count, 1, 'Should have be called once')
     self.assertEquals(service_manager.timed_slide_interval.setChecked.call_count, 1, 'Should have be called once')
开发者ID:crossroadchurch,项目名称:paul,代码行数:66,代码来源:test_servicemanager.py


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