|
@@ -1,10 +1,7 @@
|
|
|
# coding: utf-8
|
|
|
from django.core.urlresolvers import NoReverseMatch, resolve
|
|
|
from django.template import RequestContext, TemplateSyntaxError
|
|
|
-from django.test import (
|
|
|
- RequestFactory, SimpleTestCase, ignore_warnings, override_settings,
|
|
|
-)
|
|
|
-from django.utils.deprecation import RemovedInDjango110Warning
|
|
|
+from django.test import RequestFactory, SimpleTestCase, override_settings
|
|
|
|
|
|
from ..utils import setup
|
|
|
|
|
@@ -13,38 +10,32 @@ from ..utils import setup
|
|
|
class UrlTagTests(SimpleTestCase):
|
|
|
|
|
|
# Successes
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url01': '{% url "template_tests.views.client" client.id %}'})
|
|
|
+ @setup({'url01': '{% url "client" client.id %}'})
|
|
|
def test_url01(self):
|
|
|
output = self.engine.render_to_string('url01', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url02': '{% url "template_tests.views.client_action" id=client.id action="update" %}'})
|
|
|
+ @setup({'url02': '{% url "client_action" id=client.id action="update" %}'})
|
|
|
def test_url02(self):
|
|
|
output = self.engine.render_to_string('url02', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/update/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url02a': '{% url "template_tests.views.client_action" client.id "update" %}'})
|
|
|
+ @setup({'url02a': '{% url "client_action" client.id "update" %}'})
|
|
|
def test_url02a(self):
|
|
|
output = self.engine.render_to_string('url02a', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/update/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url02b': "{% url 'template_tests.views.client_action' id=client.id action='update' %}"})
|
|
|
+ @setup({'url02b': "{% url 'client_action' id=client.id action='update' %}"})
|
|
|
def test_url02b(self):
|
|
|
output = self.engine.render_to_string('url02b', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/update/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url02c': "{% url 'template_tests.views.client_action' client.id 'update' %}"})
|
|
|
+ @setup({'url02c': "{% url 'client_action' client.id 'update' %}"})
|
|
|
def test_url02c(self):
|
|
|
output = self.engine.render_to_string('url02c', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/update/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url03': '{% url "template_tests.views.index" %}'})
|
|
|
+ @setup({'url03': '{% url "index" %}'})
|
|
|
def test_url03(self):
|
|
|
output = self.engine.render_to_string('url03')
|
|
|
self.assertEqual(output, '/')
|
|
@@ -64,12 +55,6 @@ class UrlTagTests(SimpleTestCase):
|
|
|
output = self.engine.render_to_string('url06', {'v': 'Ω'})
|
|
|
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url07': '{% url "template_tests.views.client2" tag=v %}'})
|
|
|
- def test_url07(self):
|
|
|
- output = self.engine.render_to_string('url07', {'v': 'Ω'})
|
|
|
- self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
|
|
|
-
|
|
|
@setup({'url08': '{% url "метка_оператора" v %}'})
|
|
|
def test_url08(self):
|
|
|
output = self.engine.render_to_string('url08', {'v': 'Ω'})
|
|
@@ -80,55 +65,45 @@ class UrlTagTests(SimpleTestCase):
|
|
|
output = self.engine.render_to_string('url09', {'v': 'Ω'})
|
|
|
self.assertEqual(output, '/%D0%AE%D0%BD%D0%B8%D0%BA%D0%BE%D0%B4/%CE%A9/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url10': '{% url "template_tests.views.client_action" id=client.id action="two words" %}'})
|
|
|
+ @setup({'url10': '{% url "client_action" id=client.id action="two words" %}'})
|
|
|
def test_url10(self):
|
|
|
output = self.engine.render_to_string('url10', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/two%20words/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url11': '{% url "template_tests.views.client_action" id=client.id action="==" %}'})
|
|
|
+ @setup({'url11': '{% url "client_action" id=client.id action="==" %}'})
|
|
|
def test_url11(self):
|
|
|
output = self.engine.render_to_string('url11', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/==/')
|
|
|
|
|
|
- @setup({'url12': '{% url "template_tests.views.client_action" '
|
|
|
- 'id=client.id action="!$&\'()*+,;=~:@," %}'})
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
+ @setup({'url12': '{% url "client_action" id=client.id action="!$&\'()*+,;=~:@," %}'})
|
|
|
def test_url12(self):
|
|
|
output = self.engine.render_to_string('url12', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/!$&'()*+,;=~:@,/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url13': '{% url "template_tests.views.client_action" '
|
|
|
- 'id=client.id action=arg|join:"-" %}'})
|
|
|
+ @setup({'url13': '{% url "client_action" id=client.id action=arg|join:"-" %}'})
|
|
|
def test_url13(self):
|
|
|
output = self.engine.render_to_string('url13', {'client': {'id': 1}, 'arg': ['a', 'b']})
|
|
|
self.assertEqual(output, '/client/1/a-b/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url14': '{% url "template_tests.views.client_action" client.id arg|join:"-" %}'})
|
|
|
+ @setup({'url14': '{% url "client_action" client.id arg|join:"-" %}'})
|
|
|
def test_url14(self):
|
|
|
output = self.engine.render_to_string('url14', {'client': {'id': 1}, 'arg': ['a', 'b']})
|
|
|
self.assertEqual(output, '/client/1/a-b/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url15': '{% url "template_tests.views.client_action" 12 "test" %}'})
|
|
|
+ @setup({'url15': '{% url "client_action" 12 "test" %}'})
|
|
|
def test_url15(self):
|
|
|
output = self.engine.render_to_string('url15')
|
|
|
self.assertEqual(output, '/client/12/test/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url18': '{% url "template_tests.views.client" "1,2" %}'})
|
|
|
+ @setup({'url18': '{% url "client" "1,2" %}'})
|
|
|
def test_url18(self):
|
|
|
output = self.engine.render_to_string('url18')
|
|
|
self.assertEqual(output, '/client/1,2/')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
@setup({'url19': '{% url named_url client.id %}'})
|
|
|
def test_url19(self):
|
|
|
output = self.engine.render_to_string(
|
|
|
- 'url19', {'client': {'id': 1}, 'named_url': 'template_tests.views.client'}
|
|
|
+ 'url19', {'client': {'id': 1}, 'named_url': 'client'}
|
|
|
)
|
|
|
self.assertEqual(output, '/client/1/')
|
|
|
|
|
@@ -138,10 +113,8 @@ class UrlTagTests(SimpleTestCase):
|
|
|
self.assertEqual(output, '/named-client/1/')
|
|
|
|
|
|
@setup({'url21': '{% autoescape off %}'
|
|
|
- '{% url "template_tests.views.client_action" '
|
|
|
- 'id=client.id action="!$&\'()*+,;=~:@," %}'
|
|
|
+ '{% url "client_action" id=client.id action="!$&\'()*+,;=~:@," %}'
|
|
|
'{% endautoescape %}'})
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
def test_url21(self):
|
|
|
output = self.engine.render_to_string('url21', {'client': {'id': 1}})
|
|
|
self.assertEqual(output, '/client/1/!$&\'()*+,;=~:@,/')
|
|
@@ -157,8 +130,7 @@ class UrlTagTests(SimpleTestCase):
|
|
|
with self.assertRaises(NoReverseMatch):
|
|
|
self.engine.render_to_string('url-fail02')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url-fail03': '{% url "template_tests.views.client" %}'})
|
|
|
+ @setup({'url-fail03': '{% url "client" %}'})
|
|
|
def test_url_fail03(self):
|
|
|
with self.assertRaises(NoReverseMatch):
|
|
|
self.engine.render_to_string('url-fail03')
|
|
@@ -203,7 +175,6 @@ class UrlTagTests(SimpleTestCase):
|
|
|
with self.assertRaises(NoReverseMatch):
|
|
|
self.engine.render_to_string('url-fail12', {'named_url': 'no_such_view'})
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
@setup({'url-fail13': '{% url named_url %}'})
|
|
|
def test_url_fail13(self):
|
|
|
with self.assertRaises(NoReverseMatch):
|
|
@@ -240,14 +211,12 @@ class UrlTagTests(SimpleTestCase):
|
|
|
self.engine.render_to_string('url-fail19', {'named_url': 'view'})
|
|
|
|
|
|
# {% url ... as var %}
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url-asvar01': '{% url "template_tests.views.index" as url %}'})
|
|
|
+ @setup({'url-asvar01': '{% url "index" as url %}'})
|
|
|
def test_url_asvar01(self):
|
|
|
output = self.engine.render_to_string('url-asvar01')
|
|
|
self.assertEqual(output, '')
|
|
|
|
|
|
- @ignore_warnings(category=RemovedInDjango110Warning)
|
|
|
- @setup({'url-asvar02': '{% url "template_tests.views.index" as url %}{{ url }}'})
|
|
|
+ @setup({'url-asvar02': '{% url "index" as url %}{{ url }}'})
|
|
|
def test_url_asvar02(self):
|
|
|
output = self.engine.render_to_string('url-asvar02')
|
|
|
self.assertEqual(output, '/')
|