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


Python EmbedBlock.to_python方法代码示例

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


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

示例1: test_deserialize

# 需要导入模块: from wagtail.wagtailembeds.blocks import EmbedBlock [as 别名]
# 或者: from wagtail.wagtailembeds.blocks.EmbedBlock import to_python [as 别名]
    def test_deserialize(self):
        """
        Deserialising the JSONish value of an EmbedBlock (a URL) should give us an EmbedValue
        for that URL
        """
        block = EmbedBlock(required=False)

        block_val = block.to_python('http://www.example.com/foo')
        self.assertIsInstance(block_val, EmbedValue)
        self.assertEqual(block_val.url, 'http://www.example.com/foo')

        # empty values should yield None
        empty_block_val = block.to_python('')
        self.assertEqual(empty_block_val, None)
开发者ID:didorothy,项目名称:wagtail,代码行数:16,代码来源:tests.py

示例2: test_render

# 需要导入模块: from wagtail.wagtailembeds.blocks import EmbedBlock [as 别名]
# 或者: from wagtail.wagtailembeds.blocks.EmbedBlock import to_python [as 别名]
    def test_render(self, get_embed):
        get_embed.return_value = Embed(html='<h1>Hello world!</h1>')

        block = EmbedBlock()
        block_val = block.to_python('http://www.example.com/foo')

        temp = template.Template('embed: {{ embed }}')
        context = template.Context({'embed': block_val})
        result = temp.render(context)

        # Check that the embed was in the returned HTML
        self.assertIn('<h1>Hello world!</h1>', result)

        # Check that get_embed was called correctly
        get_embed.assert_any_call('http://www.example.com/foo')
开发者ID:didorothy,项目名称:wagtail,代码行数:17,代码来源:tests.py


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