Ticket #13514: 13514-regression-test.diff
File 13514-regression-test.diff, 12.2 KB (added by , 15 years ago) |
---|
-
tests/regressiontests/admin_views/tests.py
diff -r 84ec6befeb13 tests/regressiontests/admin_views/tests.py
a b 2 2 3 3 import re 4 4 import datetime 5 from django.conf import settings6 5 from django.core.files import temp as tempfile 7 6 from django.test import TestCase 8 7 from django.contrib.auth import admin # Register auth models with the admin. … … 16 15 from django.utils import formats 17 16 from django.utils.cache import get_max_age 18 17 from django.utils.html import escape 19 from django.utils.translation import get_date_formats, activate, deactivate20 18 from django.utils.encoding import iri_to_uri 21 19 22 20 # local test models 23 21 from models import Article, BarAccount, CustomArticle, EmptyModel, \ 24 ExternalSubscriber,FooAccount, Gallery, ModelWithStringPrimaryKey, \22 FooAccount, Gallery, ModelWithStringPrimaryKey, \ 25 23 Person, Persona, Picture, Podcast, Section, Subscriber, Vodcast, \ 26 24 Language, Collector, Widget, Grommet, DooHickey, FancyDoodad, Whatsit, \ 27 25 Category, Post, Plot, FunkyTag … … 272 270 response = self.client.get("/test_admin/admin/admin_views/post/") 273 271 self.failUnless('icon-unknown.gif' in response.content) 274 272 275 def testI18NLanguageNonEnglishDefault(self):276 """277 Check if the Javascript i18n view returns an empty language catalog278 if the default language is non-English but the selected language279 is English. See #13388 and #3594 for more details.280 """281 old_language_code = settings.LANGUAGE_CODE282 settings.LANGUAGE_CODE = 'fr'283 activate('en-us')284 response = self.client.get('/test_admin/admin/jsi18n/')285 self.assertNotContains(response, 'Choisir une heure')286 deactivate()287 settings.LANGUAGE_CODE = old_language_code288 289 def testI18NLanguageNonEnglishFallback(self):290 """291 Makes sure that the fallback language is still working properly292 in cases where the selected language cannot be found.293 """294 old_language_code = settings.LANGUAGE_CODE295 settings.LANGUAGE_CODE = 'fr'296 activate('none')297 response = self.client.get('/test_admin/admin/jsi18n/')298 self.assertContains(response, 'Choisir une heure')299 deactivate()300 settings.LANGUAGE_CODE = old_language_code301 302 273 303 274 class SaveAsTests(TestCase): 304 275 fixtures = ['admin-views-users.xml','admin-views-person.xml'] -
new file tests/regressiontests/views/app1/__init__.py
diff -r 84ec6befeb13 tests/regressiontests/views/app1/__init__.py
- + 1 # -
new file tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.po
diff -r 84ec6befeb13 tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo Binary file tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo has changed diff -r 84ec6befeb13 tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.po
- + 1 # SOME DESCRIPTIVE TITLE. 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 # This file is distributed under the same license as the PACKAGE package. 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 5 # 6 #, fuzzy 7 msgid "" 8 msgstr "" 9 "Project-Id-Version: PACKAGE VERSION\n" 10 "Report-Msgid-Bugs-To: \n" 11 "POT-Creation-Date: 2007-09-15 19:15+0200\n" 12 "PO-Revision-Date: 2010-05-12 12:41-0300\n" 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 "Language-Team: LANGUAGE <LL@li.org>\n" 15 "MIME-Version: 1.0\n" 16 "Content-Type: text/plain; charset=UTF-8\n" 17 "Content-Transfer-Encoding: 8bit\n" 18 19 msgid "this app1 string is to be translated" 20 msgstr "il faut traduire cette chaîne de caractères de app1" -
new file tests/regressiontests/views/app2/__init__.py
diff -r 84ec6befeb13 tests/regressiontests/views/app2/__init__.py
- + 1 # -
new file tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.po
diff -r 84ec6befeb13 tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo Binary file tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo has changed diff -r 84ec6befeb13 tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.po
- + 1 # SOME DESCRIPTIVE TITLE. 2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 # This file is distributed under the same license as the PACKAGE package. 4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. 5 # 6 #, fuzzy 7 msgid "" 8 msgstr "" 9 "Project-Id-Version: PACKAGE VERSION\n" 10 "Report-Msgid-Bugs-To: \n" 11 "POT-Creation-Date: 2007-09-15 19:15+0200\n" 12 "PO-Revision-Date: 2010-05-12 12:41-0300\n" 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 "Language-Team: LANGUAGE <LL@li.org>\n" 15 "MIME-Version: 1.0\n" 16 "Content-Type: text/plain; charset=UTF-8\n" 17 "Content-Transfer-Encoding: 8bit\n" 18 19 msgid "this app2 string is to be translated" 20 msgstr "il faut traduire cette chaîne de caractères de app1" -
tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po
diff -r 84ec6befeb13 tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo Binary file tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo has changed diff -r 84ec6befeb13 tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po
a b 9 9 "Project-Id-Version: PACKAGE VERSION\n" 10 10 "Report-Msgid-Bugs-To: \n" 11 11 "POT-Creation-Date: 2007-09-15 16:45+0200\n" 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12 "PO-Revision-Date: 2010-05-12 12:57-0300\n" 13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 14 "Language-Team: LANGUAGE <LL@li.org>\n" 15 15 "MIME-Version: 1.0\n" … … 18 18 19 19 #: media/js/translate.js:1 20 20 msgid "this is to be translated" 21 msgstr "esto tiene que ser traducido" 22 No newline at end of file 21 msgstr "esto tiene que ser traducido" 22 23 24 msgid "Choose a time" 25 msgstr "Elige una hora" -
tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po
diff -r 84ec6befeb13 tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo Binary file tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo has changed diff -r 84ec6befeb13 tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po
a b 9 9 "Project-Id-Version: PACKAGE VERSION\n" 10 10 "Report-Msgid-Bugs-To: \n" 11 11 "POT-Creation-Date: 2007-09-15 19:15+0200\n" 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12 "PO-Revision-Date: 2010-05-12 12:41-0300\n" 13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 14 "Language-Team: LANGUAGE <LL@li.org>\n" 15 15 "MIME-Version: 1.0\n" … … 17 17 "Content-Transfer-Encoding: 8bit\n" 18 18 19 19 msgid "this is to be translated" 20 msgstr "il faut le traduire" 21 No newline at end of file 20 msgstr "il faut le traduire" 21 22 23 msgid "Choose a time" 24 msgstr "Choisir une heure" -
tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.po
diff -r 84ec6befeb13 tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.mo Binary file tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.mo has changed diff -r 84ec6befeb13 tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.po
a b 9 9 "Project-Id-Version: PACKAGE VERSION\n" 10 10 "Report-Msgid-Bugs-To: \n" 11 11 "POT-Creation-Date: 2007-09-15 16:45+0200\n" 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"12 "PO-Revision-Date: 2010-05-12 12:57-0300\n" 13 13 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 14 14 "Language-Team: LANGUAGE <LL@li.org>\n" 15 15 "MIME-Version: 1.0\n" … … 17 17 "Content-Transfer-Encoding: 8bit\n" 18 18 19 19 msgid "this is to be translated" 20 msgstr "перевод" 21 No newline at end of file 20 msgstr "перевод" 21 22 23 msgid "Choose a time" 24 msgstr "Выберите время" -
tests/regressiontests/views/tests/i18n.py
diff -r 84ec6befeb13 tests/regressiontests/views/tests/i18n.py
a b 1 # -*- coding:utf-8 -*- 1 2 import gettext 2 3 3 4 from django.conf import settings 4 5 from django.test import TestCase 5 from django.utils.translation import activate 6 from django.utils.translation import activate, deactivate 6 7 from django.utils.text import javascript_quote 7 8 8 9 from regressiontests.views.urls import locale_dir … … 30 31 # javascript_quote is used to be able to check unicode strings 31 32 self.assertContains(response, javascript_quote(trans_txt), 1) 32 33 34 33 35 class JsI18NTests(TestCase): 34 36 """ 35 37 Tests django views in django/views/i18n.py that need to change … … 66 68 activate('fi') 67 69 response = self.client.get('/views/jsi18n/') 68 70 self.assertContains(response, 'il faut le traduire') 71 72 def testI18NLanguageNonEnglishDefault(self): 73 """ 74 Check if the Javascript i18n view returns an empty language catalog 75 if the default language is non-English but the selected language 76 is English. See #13388 and #3594 for more details. 77 """ 78 settings.LANGUAGE_CODE = 'fr' 79 activate('en-us') 80 response = self.client.get('/views/jsi18n/') 81 self.assertNotContains(response, 'Choisir une heure') 82 deactivate() 83 84 def testI18NLanguageNonEnglishFallback(self): 85 """ 86 Makes sure that the fallback language is still working properly 87 in cases where the selected language cannot be found. 88 """ 89 settings.LANGUAGE_CODE = 'fr' 90 activate('none') 91 response = self.client.get('/views/jsi18n/') 92 self.assertContains(response, 'Choisir une heure') 93 deactivate() 94 95 96 class JsI18NTestsMultiPackage(TestCase): 97 """ 98 Tests for django views in django/views/i18n.py that need to change 99 settings.LANGUAGE_CODE and merge JS translation from several packages. 100 """ 101 VIEW_PATH = '/views/jsi18n_multiple_packages/' 102 103 def setUp(self): 104 self.old_language_code = settings.LANGUAGE_CODE 105 self.old_installed_apps = settings.INSTALLED_APPS 106 settings.INSTALLED_APPS = list(settings.INSTALLED_APPS) + ['regressiontests.views.app1', 'regressiontests.views.app2'] 107 108 def tearDown(self): 109 settings.LANGUAGE_CODE = self.old_language_code 110 settings.INSTALLED_APPS = self.old_installed_apps 111 112 def testI18NLanguageNonEnglishDefault(self): 113 """ 114 Check if the Javascript i18n view returns a complete language catalog 115 if the default language is en-us, the selected language is available 116 and a catalog composed by djangojs domain translations of multiple 117 Python packages is requested. See #13388, #3594 and #13514 for more details. 118 """ 119 settings.LANGUAGE_CODE = 'en-us' 120 activate('fr') 121 response = self.client.get(self.VIEW_PATH) 122 #print response.content 123 self.assertContains(response, 'il faut traduire cette chaîne de caractères de app1') 124 deactivate() -
tests/regressiontests/views/urls.py
diff -r 84ec6befeb13 tests/regressiontests/views/urls.py
a b 16 16 'packages': ('regressiontests.views',), 17 17 } 18 18 19 js_info_dict_multiple_packages = { 20 'domain': 'djangojs', 21 'packages': ('regressiontests.views', 'regressiontests.views.app1', 'regressiontests.views.app2'), 22 } 23 19 24 date_based_info_dict = { 20 25 'queryset': Article.objects.all(), 21 26 'date_field': 'date_created', … … 36 41 # i18n views 37 42 (r'^i18n/', include('django.conf.urls.i18n')), 38 43 (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), 44 (r'^jsi18n_multiple_packages/$', 'django.views.i18n.javascript_catalog', js_info_dict_multiple_packages), 39 45 40 46 # Static views 41 47 (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}),