Skip to content

Commit

Permalink
Adding new test
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed May 15, 2014
1 parent 66a08aa commit 6650fd4
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions micawber/contrib/mcdjango/mcdjango_tests/tests.py
@@ -1,14 +1,44 @@
from django.template import Template, Context
from django.template import Context
from django.template import Template
from django.test import TestCase

from micawber.test_utils import test_pr, test_cache, test_pr_cache, TestProvider, BaseTestCase
from micawber.parsers import parse_text
from micawber.test_utils import BaseTestCase
from micawber.test_utils import test_cache
from micawber.test_utils import test_pr
from micawber.test_utils import test_pr_cache
from micawber.test_utils import TestProvider


class MicawberDjangoTestCase(TestCase, BaseTestCase):
def render(self, s, **params):
s = '{%% load micawber_tags %%}%s' % s
return Template(s).render(Context(params)).strip()

def test_oembed_alt(self):
from micawber.contrib.mcdjango import extension

def custom_handler(url, response_data):
return url

oembed_alt = extension(
'oembed_alt',
urlize_all=False,
block_handler=custom_handler)

text = '\n'.join((
'this is the first line',
'http://photo-test2',
'this is the third line http://photo-test2',
'http://photo-test2 this is the fourth line'))
rendered = self.render('{{ text|oembed_alt }}', text=text)
self.assertEqual(rendered.splitlines(), [
'this is the first line',
self.full_pairs['http://photo-test2'],
'this is the third line http://photo-test2',
'http://photo-test2 this is the fourth line',
])

def test_fix_wh(self):
from micawber.contrib.mcdjango import fix_width_height
self.assertEqual(fix_width_height('300x400', {}), {'maxwidth': 300, 'maxheight': 400})
Expand Down

0 comments on commit 6650fd4

Please sign in to comment.