0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-29 17:36:49 +01:00

Remove embed filter

This commit is contained in:
Matt Westcott 2016-12-16 15:07:34 +00:00
parent 3a92774f8c
commit 4c5cc5b286
2 changed files with 0 additions and 62 deletions

View File

@ -1,28 +1,14 @@
from __future__ import absolute_import, unicode_literals
import warnings
from django import template
from django.utils.safestring import mark_safe
from wagtail.utils.deprecation import RemovedInWagtail19Warning
from wagtail.wagtailembeds import embeds
from wagtail.wagtailembeds.exceptions import EmbedException
register = template.Library()
@register.filter
def embed(url, max_width=None):
warnings.warn(
"The embed filter has been converted to a template tag. "
"Use {% embed my_embed_url %} instead.",
category=RemovedInWagtail19Warning, stacklevel=2
)
return embed_tag(url, max_width)
@register.simple_tag(name='embed')
def embed_tag(url, max_width=None):
try:

View File

@ -1,7 +1,6 @@
from __future__ import absolute_import, unicode_literals
import unittest
import warnings
import django.utils.six.moves.urllib.request
from bs4 import BeautifulSoup
@ -13,7 +12,6 @@ from django.utils.six.moves.urllib.error import URLError
from mock import patch
from wagtail.tests.utils import WagtailTestUtils
from wagtail.utils.deprecation import RemovedInWagtail19Warning
from wagtail.wagtailcore import blocks
from wagtail.wagtailembeds.blocks import EmbedBlock, EmbedValue
from wagtail.wagtailembeds.embeds import get_embed
@ -24,7 +22,6 @@ from wagtail.wagtailembeds.finders.embedly import AccessDeniedEmbedlyException,
from wagtail.wagtailembeds.finders.oembed import oembed as wagtail_oembed
from wagtail.wagtailembeds.models import Embed
from wagtail.wagtailembeds.rich_text import MediaEmbedHandler
from wagtail.wagtailembeds.templatetags.wagtailembeds_tags import embed as embed_filter
from wagtail.wagtailembeds.templatetags.wagtailembeds_tags import embed_tag
try:
@ -34,9 +31,6 @@ except ImportError:
no_embedly = True
class TestGetDefaultFinder(TestCase):
def test_defaults_to_oembed(self):
self.assertEqual(get_default_finder(), wagtail_oembed)
@ -340,48 +334,6 @@ class TestOembed(TestCase):
})
class TestEmbedFilter(TestCase):
@patch('wagtail.wagtailembeds.embeds.get_embed')
def test_direct_call(self, get_embed):
with warnings.catch_warnings(record=True) as ws:
warnings.resetwarnings()
warnings.simplefilter('always')
get_embed.return_value = Embed(html='<img src="http://www.example.com" />')
result = embed_filter('http://www.youtube.com/watch/')
self.assertEqual(result, '<img src="http://www.example.com" />')
self.assertEqual(len(ws), 1)
self.assertIs(ws[0].category, RemovedInWagtail19Warning)
@patch('wagtail.wagtailembeds.embeds.get_embed')
def test_call_from_template(self, get_embed):
with warnings.catch_warnings(record=True) as ws:
warnings.resetwarnings()
warnings.simplefilter('always')
get_embed.return_value = Embed(html='<img src="http://www.example.com" />')
temp = template.Template('{% load wagtailembeds_tags %}{{ "http://www.youtube.com/watch/"|embed }}')
result = temp.render(template.Context())
self.assertEqual(result, '<img src="http://www.example.com" />')
self.assertEqual(len(ws), 1)
self.assertIs(ws[0].category, RemovedInWagtail19Warning)
@patch('wagtail.wagtailembeds.embeds.get_embed')
def test_catches_embed_not_found(self, get_embed):
with warnings.catch_warnings(record=True) as ws:
get_embed.side_effect = EmbedNotFoundException
temp = template.Template('{% load wagtailembeds_tags %}{{ "http://www.youtube.com/watch/"|embed }}')
result = temp.render(template.Context())
self.assertEqual(result, '')
self.assertEqual(len(ws), 1)
self.assertIs(ws[0].category, RemovedInWagtail19Warning)
class TestEmbedTag(TestCase):
@patch('wagtail.wagtailembeds.embeds.get_embed')
def test_direct_call(self, get_embed):