Added a test for current_app handling.

This commit is contained in:
Michael Elsdoerfer 2011-04-28 23:36:28 +02:00
parent 3364e9977f
commit 88bb90aff8
2 changed files with 15 additions and 0 deletions

View File

@ -2,4 +2,9 @@ from django.conf.urls.defaults import *
urlpatterns = patterns('',
(r'^url_test/', include('urls_app.urls')),
# These two are used to test that our url-tag implementation can
# deal with application namespaces / the "current app".
(r'^app/one/', include('urls_app.urls', app_name="testapp", namespace="testapp")), # default instance
(r'^app/two/', include('urls_app.urls', app_name="testapp", namespace="two")),
)

View File

@ -81,6 +81,16 @@ def test_url():
assert actual_result == expected_result
def test_url_current_app():
"""Test that the url can deal with the current_app context setting."""
from coffin.template.loader import get_template_from_string
from django.template import RequestContext
from django.http import HttpRequest
t = get_template_from_string('{% url testapp:the-index-view %}')
assert t.render(RequestContext(HttpRequest())) == '/app/one/'
assert t.render(RequestContext(HttpRequest(), current_app="two")) == '/app/two/'
def test_with():
from coffin.template.defaulttags import WithExtension
env = Environment(extensions=[WithExtension])