예제 #1
0
파일: tests.py 프로젝트: wgiddens/wagtail
    def test_render_within_structblock(self, get_embed):
        """
        When rendering the value of an EmbedBlock directly in a template
        (as happens when accessing it as a child of a StructBlock), the
        proper embed output should be rendered, not the URL.
        """
        get_embed.return_value = Embed(html='<h1>Hello world!</h1>')

        block = blocks.StructBlock([
            ('title', blocks.CharBlock()),
            ('embed', EmbedBlock()),
        ])

        block_val = block.to_python({
            'title': 'A test',
            'embed': 'http://www.example.com/foo'
        })

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

        self.assertIn('<h1>Hello world!</h1>', result)

        # Check that get_embed was called correctly
        get_embed.assert_any_call('http://www.example.com/foo')
예제 #2
0
파일: tests.py 프로젝트: EricSchles/wagtail
    def test_render(self, get_embed):
        get_embed.return_value = Embed(html='<h1>Hello world!</h1>')

        block = EmbedBlock()
        html = block.render('http://www.example.com')

        # Check that get_embed was called correctly
        get_embed.assert_any_call('http://www.example.com')

        # Check that the embed was in the returned HTML
        self.assertIn('<h1>Hello world!</h1>', html)
예제 #3
0
    def test_render(self, get_embed):
        get_embed.return_value = Embed(html='<h1>Hello world!</h1>')

        block = EmbedBlock()
        html = block.render('http://www.example.com')

        # Check that get_embed was called correctly
        get_embed.assert_any_call('http://www.example.com')

        # Check that the embed was in the returned HTML
        self.assertIn('<h1>Hello world!</h1>', html)
예제 #4
0
    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')
예제 #5
0
    def test_render_within_structblock(self, get_embed):
        """
        When rendering the value of an EmbedBlock directly in a template
        (as happens when accessing it as a child of a StructBlock), the
        proper embed output should be rendered, not the URL.
        """
        get_embed.return_value = Embed(html="<h1>Hello world!</h1>")

        block = blocks.StructBlock([("title", blocks.CharBlock()), ("embed", EmbedBlock())])

        block_val = block.to_python({"title": "A test", "embed": "http://www.example.com/foo"})

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

        self.assertIn("<h1>Hello world!</h1>", result)

        # Check that get_embed was called correctly
        get_embed.assert_any_call("http://www.example.com/foo")
예제 #6
0
파일: tests.py 프로젝트: didorothy/wagtail
    def test_render_within_structblock(self, get_embed):
        """
        When rendering the value of an EmbedBlock directly in a template
        (as happens when accessing it as a child of a StructBlock), the
        proper embed output should be rendered, not the URL.
        """
        get_embed.return_value = Embed(html='<h1>Hello world!</h1>')

        block = blocks.StructBlock([
            ('title', blocks.CharBlock()),
            ('embed', EmbedBlock()),
        ])

        block_val = block.to_python({'title': 'A test', 'embed': 'http://www.example.com/foo'})

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

        self.assertIn('<h1>Hello world!</h1>', result)

        # Check that get_embed was called correctly
        get_embed.assert_any_call('http://www.example.com/foo')