Ticket #13514: 13514-regression-test.2.diff

File 13514-regression-test.2.diff, 14.9 KB (added by Ramiro Morales, 14 years ago)

Fixed the regression test (use javascript_quote() in the assertContain() call, fixed typo in app2's fr djangojs.po)

  • tests/regressiontests/admin_views/tests.py

    diff --git a/tests/regressiontests/admin_views/tests.py b/tests/regressiontests/admin_views/tests.py
    a b  
    22
    33import re
    44import datetime
    5 from django.conf import settings
    65from django.core.files import temp as tempfile
    76from django.test import TestCase
    87from django.contrib.auth import admin # Register auth models with the admin.
     
    1615from django.utils import formats
    1716from django.utils.cache import get_max_age
    1817from django.utils.html import escape
    19 from django.utils.translation import get_date_formats, activate, deactivate
    2018from django.utils.encoding import iri_to_uri
    2119
    2220# local test models
    2321from models import Article, BarAccount, CustomArticle, EmptyModel, \
    24     ExternalSubscriber, FooAccount, Gallery, ModelWithStringPrimaryKey, \
     22    FooAccount, Gallery, ModelWithStringPrimaryKey, \
    2523    Person, Persona, Picture, Podcast, Section, Subscriber, Vodcast, \
    2624    Language, Collector, Widget, Grommet, DooHickey, FancyDoodad, Whatsit, \
    2725    Category, Post, Plot, FunkyTag
     
    272270        response = self.client.get("/test_admin/admin/admin_views/post/")
    273271        self.failUnless('icon-unknown.gif' in response.content)
    274272
    275     def testI18NLanguageNonEnglishDefault(self):
    276         """
    277         Check if the Javascript i18n view returns an empty language catalog
    278         if the default language is non-English but the selected language
    279         is English. See #13388 and #3594 for more details.
    280         """
    281         old_language_code = settings.LANGUAGE_CODE
    282         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_code
    288 
    289     def testI18NLanguageNonEnglishFallback(self):
    290         """
    291         Makes sure that the fallback language is still working properly
    292         in cases where the selected language cannot be found.
    293         """
    294         old_language_code = settings.LANGUAGE_CODE
    295         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_code
    301 
    302273
    303274class SaveAsTests(TestCase):
    304275    fixtures = ['admin-views-users.xml','admin-views-person.xml']
  • new file tests/regressiontests/views/app1/__init__.py

    diff --git a/tests/regressiontests/views/app1/__init__.py b/tests/regressiontests/views/app1/__init__.py
    new file mode 100644
    - +  
     1#
  • new file tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo

    diff --git a/tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.mo
    new file mode 100644
    index 0000000000000000000000000000000000000000..5d6aecb446f3b0b907f540596f8268833603678b
    GIT binary patch
    literal 482
    zc$`g<!A{#i5QYtEFFy9nVGg~~q281Ta8ray42o)pG;z2u_Fxu;U2AuO=!5hfIH0}+
    z@6l)JSRlbjpLS;T@9e*`|2}>A6G?0fJHi*?qcDnIVlI3ZehI^^D7x=g;YsqXSIu_x
    zF8Ia-&|Rk>us5~^DcQjl0efx3S~E4#+`C(<8K(_ik`Kn&6z19ZXLg>$WxiNWFJ|$A
    zI_DY7(3%EMH*LVmr4Y|ADja*#EQfF+-BK7N$pI!usD_}9QZ?L7WJiR!pnDVE>r{ft
    z5Y+(GAl+A(d=p)v17r2-&G{70Rz(4`tjuAQm)W#9$tIIUzFZ!Q)V3Sl5>}+|QYf<7
    z`Kq@(DvFb}*>k=<j>~D8zdcIrCGpr<CM$RR?!*Ms1Apz-+Su<<-)J9*f2^uAJbcsj
    zUarYwZfn=b2vaz`G8{){4cB_Z{UDo-@dPz7Q{UzJuO(<C)n3>9{OBq4W&aJ)e+vDC
    AssI20
  • new file tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.po

    diff --git a/tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/app1/locale/fr/LC_MESSAGES/djangojs.po
    new file mode 100644
    - +  
     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
     7msgid ""
     8msgstr ""
     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
     19msgid "this app1 string is to be translated"
     20msgstr "il faut traduire cette chaîne de caractères de app1"
  • new file tests/regressiontests/views/app2/__init__.py

    diff --git a/tests/regressiontests/views/app2/__init__.py b/tests/regressiontests/views/app2/__init__.py
    new file mode 100644
    - +  
     1#
  • new file tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo

    diff --git a/tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.mo
    new file mode 100644
    index 0000000000000000000000000000000000000000..17e18636727c1801f37cea95e3fd15d95e2b4234
    GIT binary patch
    literal 482
    zc$`g<!A`?442BDWOOKp6_`nSUZP5gjfhb!+6YUsV$33*B1dXIhya^tJci@0{3EqQe
    z!4;rk=~I43e;mj8+E{z_I98cWW`|j4y53KWm@Vdp>8yC(qFtGH)+^pJR{sP&C<n4>
    zB5-7tu7OiBaECxvYB!UFl{d2H5la$-O5CD#%IFwIN$)DTOyM>iPX^aRe~gW>Byv})
    zN}SJYCkhjTKe{eN&!QwgB>G$}hA0RQL~ta+4unT>*x3$vhmB&43+4X%!axKa5k?S2
    zF^gcIeVKG5ir?Ohjp1UNWiU+g6uN1i46?JN-yf%w$thcPJ(o3#0_9T-Su(twwk>zF
    z>};lXjjd1pe2}NhM}@nA-!qy}^Bpe@H$nJJd(BKLeGKJ;v<~THT3m?3rLXPf9<4}q
    vX(}FJ42O4$d{52bUe2i<WHnb7p+q8Vt9*WFgo>rKvZT*9i>^)EZ}7eW4QGU{
  • new file tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.po

    diff --git a/tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/app2/locale/fr/LC_MESSAGES/djangojs.po
    new file mode 100644
    - +  
     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
     7msgid ""
     8msgstr ""
     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 22:05-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
     19msgid "this app2 string is to be translated"
     20msgstr "il faut traduire cette chaîne de caractères de app2"
  • tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo

    diff --git a/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.mo
    index 01c002e9e0e3878edd15a03a3d997c0e5124ef33..b6b088752a01696046502cda6205ccd9bccb6487
    GIT binary patch
    literal 490
    zc$`g;O-{ow5QSZSHj!Y#iUo_=BSTUMKLM(SHlT{6RBhTdrWsPB)-JY#;09cP>u>|E
    zz*(58m0;vgBU$f_pXX<1<C9UX6MMulu}P$CSr5b(A&6Z<6Jd?959-^*S8eJ0re0fl
    z)>eHnleH#VTLb}4&XBo@v_QvcctmhUC_5Dn3)VCG8OM%y3O+((rB)I2;?`Y!o4_dP
    z4?6c<ua9$W9M5bi3w~XdmghPGuXmsGmO<gj#M?A2g1YaYa{rtMAp|GUak%f(4GDQ4
    zU#0!83w-W}Jg7rZk3#YskuDY1@qCp{n+R@(X$svqOW-oe;!fI(+wFcb7&J(#%1V^T
    za}=`((zts&TtvQ1)8<qjXj3-4tdk{wp9&6qucehkMQ^;%DTKo}cQ~I4sV-nV5yqms
    z8s<0r>`%AI@`Q#bYOD*X$_UOLrSn)al_f%@1WdFM3@z=|NmK|g6@o>xSaDH}Wue(G
    DUSfgM
  • tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po

    diff --git a/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/locale/es/LC_MESSAGES/djangojs.po
    a b  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    1111"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"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1414"Language-Team: LANGUAGE <LL@li.org>\n"
    1515"MIME-Version: 1.0\n"
     
    1818
    1919#: media/js/translate.js:1
    2020msgid "this is to be translated"
    21 msgstr "esto tiene que ser traducido"
    22  No newline at end of file
     21msgstr "esto tiene que ser traducido"
     22
     23
     24msgid "Choose a time"
     25msgstr "Elige una hora"
  • tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo

    diff --git a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.mo
    index 4feca0b44d69463a63957c4869ca210ba7bce725..356147cf11c3f3a9765a75abba326f449f4c5bad
    GIT binary patch
    literal 484
    zc$`g;OHRWu5QbA8n@B8x4GR{tM*~Tr0>VRtHlT{6RBg%{(+sImuq)d^a04#DbvOej
    z;4Dm`QW^QvZ;k#LkLP=1<-_AxX119FW|c|3zqn`C7{P2YnrSsW@11p>`Q-a1>lbTd
    zUb8gUSx>J$(b^ISaPpZvH<1?jI1LX3&In~I;i&NXMnBQmVYk3LGFEC8K|gNa#McSj
    zC4*u2w&xFMs*S_Uma@Rhy0n<<2>kwSj%`E2aS?X7TLjG@IK<!>!xn_cQP|oEIKxI9
    z(2KPHePMt>3&SRa&FCP+V4r=dunzP2Y}!O{HA++H#aRNUNfvk0i@4JnB*Wo3TUA+$
    zk}xOn96=iQu1B+xPt)|GlDpcJ=YH1BlEtUO-N0{a<w)@xZ&Mz^(W~2=Rzj*17*B+;
    z<jzL<6&@{ovsoU=V4}vlkgAN}=s`Mvwp{*>fm#tvs5a!u3LZu6p!(fzQA^JK08zYu
    AnE(I)
  • tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po

    diff --git a/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/locale/fr/LC_MESSAGES/djangojs.po
    a b  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    1111"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"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1414"Language-Team: LANGUAGE <LL@li.org>\n"
    1515"MIME-Version: 1.0\n"
     
    1717"Content-Transfer-Encoding: 8bit\n"
    1818
    1919msgid "this is to be translated"
    20 msgstr "il faut le traduire"
    21  No newline at end of file
     20msgstr "il faut le traduire"
     21
     22
     23msgid "Choose a time"
     24msgstr "Choisir une heure"
  • tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.mo

    diff --git a/tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.mo b/tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.mo
    index 148cba533bfe58b81654c876767e3053988250f6..21659a93d3ed61229fb0d6cb100f64391ded2b28
    GIT binary patch
    literal 489
    zc$`g-&uZI15XRSOa}l(MoC@t>?qO5OjZ#PXLsVG_rjlc1+2^k9jl99pn%zxEZy~2b
    z4~0S>q^5!#iu(%dYY%;vjuS(&?2m64zM1{@-^TMF1kW?%4YG}_BMEsppO6;_LtY^g
    z@oR*9L4A$Pv3`mA7qzyUSzGCHCyB;VY7PvHxZuQ$g$BGv!hnNOtke@`_=t3rJm*70
    zTO-=%N()&A&<UfD;YkerIP11f+fK%(QW=`+LX7B#%R<v!2H<o~a~dhm3=YvIZVRC9
    zy6>sGOFbXFonYJFbg_d*n(-^4pZYwPx<2*l;MD^kXWpSNVcO7ql})Muj(bT0?J$jD
    zKTg9|auhb3S={X&qO~k8S;1+}*+l?J*gokkBkw24(L`)XRUA5LD~%sN<!!l6Bum3f
    zeB<*JLl}N--cBb>lzT87Go`sX=;g<>@#tG-Ipd1P<xq}9Sp?7+2;&g@eeu=)wAJFq
    b-Ysrz1$KsIWq&We5&P%9U)h<R+h62AFD#FK
  • tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.po

    diff --git a/tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.po b/tests/regressiontests/views/locale/ru/LC_MESSAGES/djangojs.po
    a b  
    99"Project-Id-Version: PACKAGE VERSION\n"
    1010"Report-Msgid-Bugs-To: \n"
    1111"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"
    1313"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
    1414"Language-Team: LANGUAGE <LL@li.org>\n"
    1515"MIME-Version: 1.0\n"
     
    1717"Content-Transfer-Encoding: 8bit\n"
    1818
    1919msgid "this is to be translated"
    20 msgstr "перевод"
    21  No newline at end of file
     20msgstr "перевод"
     21
     22
     23msgid "Choose a time"
     24msgstr "Выберите время"
  • tests/regressiontests/views/tests/i18n.py

    diff --git a/tests/regressiontests/views/tests/i18n.py b/tests/regressiontests/views/tests/i18n.py
    a b  
     1# -*- coding:utf-8 -*-
    12import gettext
    23
    34from django.conf import settings
    45from django.test import TestCase
    5 from django.utils.translation import activate
     6from django.utils.translation import activate, deactivate
    67from django.utils.text import javascript_quote
    78
    89from regressiontests.views.urls import locale_dir
     
    3031            # javascript_quote is used to be able to check unicode strings
    3132            self.assertContains(response, javascript_quote(trans_txt), 1)
    3233
     34
    3335class JsI18NTests(TestCase):
    3436    """
    3537    Tests django views in django/views/i18n.py that need to change
     
    6668        activate('fi')
    6769        response = self.client.get('/views/jsi18n/')
    6870        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
     96class 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, javascript_quote('il faut traduire cette chaîne de caractères de app1'))
     124        deactivate()
  • tests/regressiontests/views/urls.py

    diff --git a/tests/regressiontests/views/urls.py b/tests/regressiontests/views/urls.py
    a b  
    1616    'packages': ('regressiontests.views',),
    1717}
    1818
     19js_info_dict_multiple_packages = {
     20    'domain': 'djangojs',
     21    'packages': ('regressiontests.views', 'regressiontests.views.app1', 'regressiontests.views.app2'),
     22}
     23
    1924date_based_info_dict = {
    2025    'queryset': Article.objects.all(),
    2126    'date_field': 'date_created',
     
    3641    # i18n views
    3742    (r'^i18n/', include('django.conf.urls.i18n')),
    3843    (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),
    3945
    4046    # Static views
    4147    (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': media_dir}),
Back to Top