summaryrefslogtreecommitdiff
path: root/tests/i18n/patterns
diff options
context:
space:
mode:
authorSjoerd Job Postmus <sjoerdjob@sjec.nl>2016-10-20 19:29:04 +0200
committerTim Graham <timograham@gmail.com>2017-09-20 18:04:42 -0400
commitdf41b5a05d4e00e80e73afe629072e37873e767a (patch)
treebaaf71ae695e2d3af604ea0d663284cb406c71e4 /tests/i18n/patterns
parentc4c128d67c7dc2830631c6859a204c9d259f1fb1 (diff)
downloaddjango-df41b5a05d4e00e80e73afe629072e37873e767a.tar.gz
Fixed #28593 -- Added a simplified URL routing syntax per DEP 0201.
Thanks Aymeric Augustin for shepherding the DEP and patch review. Thanks Marten Kenbeek and Tim Graham for contributing to the code. Thanks Tom Christie, Shai Berger, and Tim Graham for the docs.
Diffstat (limited to 'tests/i18n/patterns')
-rw-r--r--tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mobin697 -> 752 bytes
-rw-r--r--tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po4
-rw-r--r--tests/i18n/patterns/tests.py16
-rw-r--r--tests/i18n/patterns/urls/namespace.py2
4 files changed, 22 insertions, 0 deletions
diff --git a/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo b/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo
index e3109784c7..5eac50466c 100644
--- a/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo
+++ b/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo
Binary files differ
diff --git a/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po b/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po
index 5c31aa7f8a..a938e3371d 100644
--- a/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po
+++ b/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po
@@ -36,3 +36,7 @@ msgstr "^profiel/"
#: urls/namespace.py:9 urls/wrong_namespace.py:10
msgid "^register/$"
msgstr "^registreren/$"
+
+#: urls/namespace.py:12
+msgid "register-as-path/"
+msgstr "registreren-als-pad/"
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index de154c2343..2423614f08 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -155,6 +155,8 @@ class URLTranslationTests(URLTestCaseBase):
self.assertEqual(translate_url('/en/users/', 'nl'), '/nl/gebruikers/')
# Namespaced URL
self.assertEqual(translate_url('/en/account/register/', 'nl'), '/nl/profiel/registreren/')
+ # path() URL pattern
+ self.assertEqual(translate_url('/en/account/register-as-path/', 'nl'), '/nl/profiel/registreren-als-pad/')
self.assertEqual(translation.get_language(), 'en')
with translation.override('nl'):
@@ -169,9 +171,11 @@ class URLNamespaceTests(URLTestCaseBase):
def test_account_register(self):
with translation.override('en'):
self.assertEqual(reverse('account:register'), '/en/account/register/')
+ self.assertEqual(reverse('account:register-as-path'), '/en/account/register-as-path/')
with translation.override('nl'):
self.assertEqual(reverse('account:register'), '/nl/profiel/registreren/')
+ self.assertEqual(reverse('account:register-as-path'), '/nl/profiel/registreren-als-pad/')
class URLRedirectTests(URLTestCaseBase):
@@ -322,6 +326,18 @@ class URLResponseTests(URLTestCaseBase):
self.assertEqual(response['content-language'], 'pt-br')
self.assertEqual(response.context['LANGUAGE_CODE'], 'pt-br')
+ def test_en_path(self):
+ response = self.client.get('/en/account/register-as-path/')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response['content-language'], 'en')
+ self.assertEqual(response.context['LANGUAGE_CODE'], 'en')
+
+ def test_nl_path(self):
+ response = self.client.get('/nl/profiel/registreren-als-pad/')
+ self.assertEqual(response.status_code, 200)
+ self.assertEqual(response['content-language'], 'nl')
+ self.assertEqual(response.context['LANGUAGE_CODE'], 'nl')
+
class URLRedirectWithScriptAliasTests(URLTestCaseBase):
"""
diff --git a/tests/i18n/patterns/urls/namespace.py b/tests/i18n/patterns/urls/namespace.py
index 2f19640d37..9858c8cd5e 100644
--- a/tests/i18n/patterns/urls/namespace.py
+++ b/tests/i18n/patterns/urls/namespace.py
@@ -1,4 +1,5 @@
from django.conf.urls import url
+from django.urls import path
from django.utils.translation import gettext_lazy as _
from django.views.generic import TemplateView
@@ -8,4 +9,5 @@ app_name = 'account'
urlpatterns = [
url(_(r'^register/$'), view, name='register'),
url(_(r'^register-without-slash$'), view, name='register-without-slash'),
+ path(_('register-as-path/'), view, name='register-as-path'),
]