diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-02-13 04:24:58 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-02-13 04:24:58 +0000 |
| commit | 0fabbf8ce849dd744d085bae073add038d574e2f (patch) | |
| tree | b120649a485282178910f3a29bfcaacb94f231b4 /tests | |
| parent | 58ae80b5ea66c0723571e233bd22d02403ba7fa7 (diff) | |
Fixed #2606 -- Added tag for working out the URL of a particular view function.
All work done by Ivan Sagalaev.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4494 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/templates/tests.py | 11 | ||||
| -rw-r--r-- | tests/regressiontests/templates/urls.py | 10 | ||||
| -rw-r--r-- | tests/regressiontests/templates/views.py | 10 | ||||
| -rw-r--r-- | tests/urls.py | 3 |
4 files changed, 34 insertions, 0 deletions
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index cb0fe7eb9a..3bae6a2609 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -645,6 +645,17 @@ class Templates(unittest.TestCase): # Compare to a given parameter 'timeuntil04' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=1), 'b':NOW - timedelta(days=2)}, '1 day'), 'timeuntil05' : ('{{ a|timeuntil:b }}', {'a':NOW - timedelta(days=2), 'b':NOW - timedelta(days=2, minutes=1)}, '1 minute'), + + ### URL TAG ######################################################## + # Successes + 'url01' : ('{% url regressiontests.templates.views.client client.id %}', {'client': {'id': 1}}, '/url_tag/client/1/'), + 'url02' : ('{% url regressiontests.templates.views.client_action client.id,action="update" %}', {'client': {'id': 1}}, '/url_tag/client/1/update/'), + 'url03' : ('{% url regressiontests.templates.views.index %}', {}, '/url_tag/'), + + # Failures + 'url04' : ('{% url %}', {}, template.TemplateSyntaxError), + 'url05' : ('{% url no_such_view %}', {}, ''), + 'url06' : ('{% url regressiontests.templates.views.client no_such_param="value" %}', {}, ''), } # Register our custom template loader. diff --git a/tests/regressiontests/templates/urls.py b/tests/regressiontests/templates/urls.py new file mode 100644 index 0000000000..dc5b36b08b --- /dev/null +++ b/tests/regressiontests/templates/urls.py @@ -0,0 +1,10 @@ +from django.conf.urls.defaults import * +from regressiontests.templates import views + +urlpatterns = patterns('', + + # Test urls for testing reverse lookups + (r'^$', views.index), + (r'^client/(\d+)/$', views.client), + (r'^client/(\d+)/(?P<action>[^/]+)/$', views.client_action), +) diff --git a/tests/regressiontests/templates/views.py b/tests/regressiontests/templates/views.py new file mode 100644 index 0000000000..b68809944a --- /dev/null +++ b/tests/regressiontests/templates/views.py @@ -0,0 +1,10 @@ +# Fake views for testing url reverse lookup + +def index(request): + pass + +def client(request, id): + pass + +def client_action(request, id, action): + pass diff --git a/tests/urls.py b/tests/urls.py index 39d5aaee6b..9fefd93624 100644 --- a/tests/urls.py +++ b/tests/urls.py @@ -7,4 +7,7 @@ urlpatterns = patterns('', # Always provide the auth system login and logout views (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'login.html'}), (r'^accounts/logout/$', 'django.contrib.auth.views.login'), + + # test urlconf for {% url %} template tag + (r'^url_tag/', include('regressiontests.templates.urls')), ) |
