Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixing w/h and testing

  • Loading branch information...
commit 466656aa07958a3692306bed5a4c11fe38f88106 1 parent 61e3429
@coleifer coleifer authored
View
2  micawber/contrib/mcdjango/__init__.py
@@ -35,7 +35,7 @@ def fix_width_height(width_height, params):
if 'x' in width_height:
params['maxwidth'], params['maxheight'] = map(int, width_height.split('x'))
else:
- params['maxwidth'] = int(width_height[0])
+ params['maxwidth'] = int(width_height)
params.pop('maxheight', None)
return params
View
17 micawber/contrib/mcdjango/mcdjango_tests/tests.py
@@ -9,10 +9,15 @@ def render(self, s, **params):
s = '{%% load micawber_tags %%}%s' % s
return Template(s).render(Context(params)).strip()
+ def test_fix_wh(self):
+ from micawber.contrib.mcdjango import fix_width_height
+ self.assertEqual(fix_width_height('300x400', {}), {'maxwidth': 300, 'maxheight': 400})
+ self.assertEqual(fix_width_height('300', {}), {'maxwidth': 300})
+
def test_provider_loading(self):
from micawber.contrib.mcdjango import providers
self.assertEqual(providers, test_pr)
-
+
def test_oembed_filter_multiline_plain(self):
for url, expected in self.full_pairs.items():
expected_inline = self.inline_pairs[url]
@@ -22,7 +27,7 @@ def test_oembed_filter_multiline_plain(self):
parsed = self.render('{{ test_str|oembed }}', test_str=test_str)
self.assertEqual(parsed, frame % (expected_inline, expected, expected_inline))
-
+
def test_oembed_filter_multiline_html(self):
for url, expected in self.full_pairs.items():
expected_inline = self.inline_pairs[url]
@@ -41,7 +46,7 @@ def test_oembed_filter_multiline_html(self):
parsed = self.render('{{ test_str|oembed_html }}', test_str=test_str)
self.assertEqual(parsed, frame % (url, expected_inline, expected_inline))
-
+
def test_urlize(self):
u1 = 'http://fappio.com/'
u2 = 'http://google.com/fap/'
@@ -55,7 +60,7 @@ def test_urlize(self):
parsed = self.render('{{ test_str|oembed }}', test_str=test_str)
self.assertEqual(parsed, frame % (u1h, u2h, expected, expected_inline))
-
+
def test_oembed_filter_extension(self):
for url, expected in self.full_pairs.items():
expected_inline = self.inline_pairs[url]
@@ -65,7 +70,7 @@ def test_oembed_filter_extension(self):
parsed = self.render('{{ test_str|oembed_no_urlize }}', test_str=test_str)
self.assertEqual(parsed, frame % (expected, expected_inline))
-
+
def test_extract_filter(self):
blank = 'http://fapp.io/foo/'
frame = 'test %s\n%s\n%s\n%s at last'
@@ -78,7 +83,7 @@ def test_extract_filter(self):
test_str = frame % (url, blank, url, blank)
rendered = self.render(t, test_str=test_str)
self.assertEqual(rendered, url)
-
+
test_str = frame_html % (url, blank, url, blank)
rendered = self.render(t, test_str=test_str)
self.assertEqual(rendered, url)
Please sign in to comment.
Something went wrong with that request. Please try again.