aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Firshman2014-09-21 00:31:45 +0200
committerBen Firshman2014-09-21 00:31:45 +0200
commit26a2bf299401551f37b84a9a6013190c4dcfaccf (patch)
tree390137678c0af543bd7688735bc2b38ace91a7b6
parentbb3953ae2e5ea820f9f3d056b8462f20601969dc (diff)
parentba40cdce1451ef335d54cc8cf04b1c98a7fce170 (diff)
downloaddjango-shorturls-26a2bf299401551f37b84a9a6013190c4dcfaccf.tar.bz2
Merge pull request #5 from mjumbewu/pullfrom
In the tests, pass a Context instead of a dict to the template to render
-rw-r--r--src/shorturls/tests/test_templatetag.py15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/shorturls/tests/test_templatetag.py b/src/shorturls/tests/test_templatetag.py
index 2feef91..2127817 100644
--- a/src/shorturls/tests/test_templatetag.py
+++ b/src/shorturls/tests/test_templatetag.py
@@ -1,4 +1,4 @@
-from django import template
+from django.template import Template, Context
from django.conf import settings
from django.test import TestCase
from shorturls.tests.models import Animal, Vegetable, Mineral
@@ -15,7 +15,7 @@ class RedirectViewTestCase(TestCase):
'A': 'shorturls.animal',
'V': 'shorturls.vegetable',
}
-
+
def tearDown(self):
if self.old_shorten is not None:
settings.SHORTEN_MODELS = self.old_shorten
@@ -23,12 +23,12 @@ class RedirectViewTestCase(TestCase):
settings.SHORT_BASE_URL = self.old_base
def render(self, t, **c):
- return template.Template('{% load shorturl %}'+t).render(c)
-
+ return Template('{% load shorturl %}'+t).render(Context(c))
+
def test_shorturl(self):
r = self.render('{% shorturl a %}', a=Animal.objects.get(id=12345))
self.assertEqual(r, '/ADNH')
-
+
def test_bad_context(self):
r = self.render('{% shorturl a %}')
self.assertEqual(r, '')
@@ -36,13 +36,12 @@ class RedirectViewTestCase(TestCase):
def test_no_prefix(self):
r = self.render('{% shorturl m %}', m=Mineral.objects.all()[0])
self.assertEqual(r, '')
-
+
def test_short_base_url(self):
settings.SHORT_BASE_URL = 'http://example.com/'
r = self.render('{% shorturl a %}', a=Animal.objects.get(id=12345))
self.assertEqual(r, 'http://example.com/ADNH')
-
+
def test_revcanonical(self):
r = self.render('{% revcanonical a %}', a=Animal.objects.get(id=12345))
self.assertEqual(r, '<link rev="canonical" href="/ADNH">')
- \ No newline at end of file