mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 01:03:11 +00:00
Add more embeds tests
This commit is contained in:
parent
e2f8debcff
commit
cdd3144107
1 changed files with 22 additions and 0 deletions
|
|
@ -309,6 +309,17 @@ class TestEmbedlyFilter(TestCase):
|
|||
@patch('urllib2.urlopen')
|
||||
@patch('json.loads')
|
||||
def test_render_embed_filter(self, loads, urlopen):
|
||||
urlopen.return_value = self.dummy_response
|
||||
loads.return_value = {'type': 'photo',
|
||||
'url': 'http://www.example.com'}
|
||||
temp = template.Template("{% load embed_filters %}{{ 'http://www.youtube.com/watch/'|embed }}")
|
||||
context = template.Context()
|
||||
result = temp.render(context)
|
||||
self.assertEqual(result, '<img src="http://www.example.com" />')
|
||||
|
||||
@patch('urllib2.urlopen')
|
||||
@patch('json.loads')
|
||||
def test_render_embedly_filter(self, loads, urlopen):
|
||||
urlopen.return_value = self.dummy_response
|
||||
loads.return_value = {'type': 'photo',
|
||||
'url': 'http://www.example.com'}
|
||||
|
|
@ -316,3 +327,14 @@ class TestEmbedlyFilter(TestCase):
|
|||
context = template.Context()
|
||||
result = temp.render(context)
|
||||
self.assertEqual(result, '<img src="http://www.example.com" />')
|
||||
|
||||
@patch('urllib2.urlopen')
|
||||
@patch('json.loads')
|
||||
def test_render_embed_filter_nonexistent_type(self, loads, urlopen):
|
||||
urlopen.return_value = self.dummy_response
|
||||
loads.return_value = {'type': 'foo',
|
||||
'url': 'http://www.example.com'}
|
||||
temp = template.Template("{% load embed_filters %}{{ 'http://www.youtube.com/watch/'|embed }}")
|
||||
context = template.Context()
|
||||
result = temp.render(context)
|
||||
self.assertEqual(result, '')
|
||||
|
|
|
|||
Loading…
Reference in a new issue