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


Python ServiceItem.name方法代码示例

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


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

示例1: add_from_command_for_a_presentation_thumb_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import name [as 别名]
    def add_from_command_for_a_presentation_thumb_test(self, mocked_get_section_data_path):
        """
        Test the Service Item - adding a presentation, and updating the thumb path
        """
        # 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.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')
开发者ID:crossroadchurch,项目名称:paul,代码行数:27,代码来源:test_serviceitem.py

示例2: serviceitem_add_image_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import name [as 别名]
    def serviceitem_add_image_test(self):
        """
        Test the Service Item - add image test
        """
        # GIVEN: A new service item and a mocked renderer
        service_item = ServiceItem(None)
        service_item.name = u'test'

        # WHEN: adding image to a service item
        test_image = os.path.join(TESTPATH, u'church.jpg')
        service_item.add_from_image(test_image, u'Image Title')

        # THEN: We should get back a valid service item
        assert service_item.is_valid is True, u'The new service item should be valid'
        assert len(service_item._display_frames) == 0, u'The service item has no display frames'

        # THEN: We should have a page of output.
        assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has display frames'
        assert service_item.get_rendered_frame(0) == test_image

        # WHEN: adding a second image to a service item
        service_item.add_from_image(test_image, u'Image1 Title')

        # THEN: We should have an increased page of output.
        assert len(service_item._raw_frames) == 2, u'A valid rendered Service Item has display frames'
        assert service_item.get_rendered_frame(0) == test_image
        assert service_item.get_rendered_frame(0) == service_item.get_rendered_frame(1)

        # WHEN requesting a saved service item
        service = service_item.get_service_repr(True)

        # THEN: We should have two parts of the service.
        assert len(service) == 2, u'A saved service has two parts'
        assert service[u'header'][u'name']  == u'test' , u'A test plugin was returned'
        assert service[u'data'][0][u'title'] == u'Image Title' , u'The first title name matches the request'
        assert service[u'data'][0][u'path'] == test_image , u'The first image name matches'
        assert service[u'data'][0][u'title'] != service[u'data'][1][u'title'], \
            u'The individual titles should not match'
        assert service[u'data'][0][u'path'] == service[u'data'][1][u'path'], u'The file paths should match'

        # WHEN validating a service item
        service_item.validate_item([u'jpg'])

        # THEN the service item should be valid
        assert service_item.is_valid is True, u'The new service item should be valid'

        # WHEN: adding a second image to a service item
        service_item.add_from_image(u'resources/church1.jpg', u'Image1 Title')

        # WHEN validating a service item
        service_item.validate_item([u'jpg'])

        # THEN the service item should be valid
        assert service_item.is_valid is False, u'The service item is not valid due to validation changes'
开发者ID:marmyshev,项目名称:transitions,代码行数:56,代码来源:test_serviceitem.py

示例3: serviceitem_add_command_test

# 需要导入模块: from openlp.core.lib import ServiceItem [as 别名]
# 或者: from openlp.core.lib.ServiceItem import name [as 别名]
    def serviceitem_add_command_test(self):
        """
        Test the Service Item - add command test
        """
        # GIVEN: A new service item and a mocked renderer
        service_item = ServiceItem(None)
        service_item.name = u'test'

        # WHEN: adding image to a service item
        test_file = os.path.join(TESTPATH, u'church.jpg')
        service_item.add_from_command(TESTPATH, u'church.jpg', test_file)

        # THEN: We should get back a valid service item
        assert service_item.is_valid is True, u'The new service item should be valid'
        assert len(service_item._display_frames) == 0, u'The service item has no display frames '

        # THEN: We should have a page of output.
        assert len(service_item._raw_frames) == 1, u'A valid rendered Service Item has one raw frame'
        assert service_item.get_rendered_frame(0) == test_file, u'The image matches the input'

        # WHEN requesting a saved service item
        service = service_item.get_service_repr(True)

        # THEN: We should have two parts of the service.
        assert len(service) == 2, u'A saved service has two parts'
        assert service[u'header'][u'name']  == u'test' , u'A test plugin'
        assert service[u'data'][0][u'title'] == u'church.jpg' , u'The first title name '
        assert service[u'data'][0][u'path'] == TESTPATH , u'The first image name'
        assert service[u'data'][0][u'image'] == test_file , u'The first image name'

        # WHEN validating a service item
        service_item.validate_item([u'jpg'])

        # THEN the service item should be valid
        assert service_item.is_valid is True, u'The service item should be valid'

        # WHEN validating a service item with a different suffix
        service_item.validate_item([u'png'])

        # THEN the service item should not be valid
        assert service_item.is_valid is False, u'The service item is not valid'
开发者ID:marmyshev,项目名称:transitions,代码行数:43,代码来源:test_serviceitem.py


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