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')
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", None, None)
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')
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", None, None)
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')