diff --git a/wagtail/wagtailembeds/format.py b/wagtail/wagtailembeds/format.py index abbb6b54b3..cba95eb55a 100644 --- a/wagtail/wagtailembeds/format.py +++ b/wagtail/wagtailembeds/format.py @@ -2,12 +2,12 @@ from __future__ import division # Use true division from django.template.loader import render_to_string -from wagtail.wagtailembeds.embeds import get_embed +from wagtail.wagtailembeds import embeds def embed_to_frontend_html(url): try: - embed = get_embed(url) + embed = embeds.get_embed(url) if embed is not None: # Work out ratio if embed.width and embed.height: @@ -27,7 +27,7 @@ def embed_to_frontend_html(url): def embed_to_editor_html(url): - embed = get_embed(url) + embed = embeds.get_embed(url) if embed is None: return diff --git a/wagtail/wagtailembeds/tests.py b/wagtail/wagtailembeds/tests.py index e02e8ce255..b6eb2a91b9 100644 --- a/wagtail/wagtailembeds/tests.py +++ b/wagtail/wagtailembeds/tests.py @@ -317,7 +317,7 @@ class TestEmbedBlock(TestCase): serialized_empty_val = block.get_prep_value(None) self.assertEqual(serialized_empty_val, '') - @patch('wagtail.wagtailembeds.format.get_embed') + @patch('wagtail.wagtailembeds.embeds.get_embed') def test_render(self, get_embed): get_embed.return_value = Embed(html='
URL: http://www.youtube.com/watch/
', result) self.assertIn('Provider: test provider name
', result) self.assertIn('Author: test author name
', result) - self.assertIn('', result) + self.assertIn('', result) + + @patch('wagtail.wagtailembeds.embeds.get_embed') + def test_expand_db_attributes(self, get_embed): + get_embed.return_value = Embed( + url='http://www.youtube.com/watch/', + max_width=None, + type='video', + html='test html', + title='test title', + author_name='test author name', + provider_name='test provider name', + thumbnail_url='htto://test/thumbnail.url', + width=1000, + height=1000, + ) - @patch('wagtail.wagtailembeds.embeds.oembed') - def test_expand_db_attributes_not_for_editor(self, oembed): - oembed.return_value = { - 'title': 'test title', - 'author_name': 'test author name', - 'provider_name': 'test provider name', - 'type': 'test type', - 'thumbnail_url': 'test thumbnail url', - 'width': 'test width', - 'height': 'test height', - 'html': 'test html' - } result = MediaEmbedHandler.expand_db_attributes( {'url': 'http://www.youtube.com/watch/'}, False