From df41b5a05d4e00e80e73afe629072e37873e767a Mon Sep 17 00:00:00 2001 From: Sjoerd Job Postmus Date: Thu, 20 Oct 2016 19:29:04 +0200 Subject: 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. --- tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo | Bin 697 -> 752 bytes tests/i18n/patterns/locale/nl/LC_MESSAGES/django.po | 4 ++++ tests/i18n/patterns/tests.py | 16 ++++++++++++++++ tests/i18n/patterns/urls/namespace.py | 2 ++ 4 files changed, 22 insertions(+) (limited to 'tests/i18n/patterns') 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 Binary files a/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo and b/tests/i18n/patterns/locale/nl/LC_MESSAGES/django.mo 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'), ] -- cgit v1.3