Ticket #5496: django_views_tests.diff

File django_views_tests.diff, 9.1 KB (added by Manuel Saelices, 17 years ago)

Several tests in a new directory for testing django views

  • tests/regressiontests/django_views/locale/en/LC_MESSAGES/djangojs.po

    No se puede mostrar: el archivo está marcado como binario.
    svn:mime-type = application/octet-stream
    
    Cambios de propiedades en tests/regressiontests/django_views/locale/en/LC_MESSAGES/djangojs.mo
    ___________________________________________________________________
    Nombre: svn:mime-type
       + application/octet-stream
    
     
     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 16:45+0200\n"
     12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\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 is to be translated"
     20msgstr "this is to be translated in english"
  • tests/regressiontests/django_views/locale/es/LC_MESSAGES/djangojs.po

    No se puede mostrar: el archivo está marcado como binario.
    svn:mime-type = application/octet-stream
    
    Cambios de propiedades en tests/regressiontests/django_views/locale/es/LC_MESSAGES/djangojs.mo
    ___________________________________________________________________
    Nombre: svn:mime-type
       + application/octet-stream
    
     
     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 16:45+0200\n"
     12"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\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#: media/js/translate.js:1
     20msgid "this is to be translated"
     21msgstr "esto tiene que ser traducido"
  • tests/regressiontests/django_views/locale/fr/LC_MESSAGES/djangojs.po

    No se puede mostrar: el archivo está marcado como binario.
    svn:mime-type = application/octet-stream
    
    Cambios de propiedades en tests/regressiontests/django_views/locale/fr/LC_MESSAGES/djangojs.mo
    ___________________________________________________________________
    Nombre: svn:mime-type
       + application/octet-stream
    
     
     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: YEAR-MO-DA HO:MI+ZONE\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 is to be translated"
     20msgstr "il faut le traduire"
  • tests/regressiontests/django_views/views.py

     
     1from django.http import HttpResponse
     2from django.template import RequestContext
     3from django.shortcuts import render_to_response
     4
     5
     6def index_page(request):
     7    """ Dummy index page """
     8    return HttpResponse('<html><body>Dummy page</body></html>')
     9
     10
     11def jsi18n_test(request):
     12    """ View for testing javascript message files """
     13    return render_to_response('js_i18n.html', {})
     14 Sin fin-de-línea al final del archivo
  • tests/regressiontests/django_views/models.py

     
     1"""
     2Regression tests for Django Views
     3"""
     4
     5from os import path
     6import gettext
     7
     8from django.conf import settings
     9from django.test import Client, TestCase
     10from django.contrib.sessions.models import Session
     11from django.utils.translation import activate
     12
     13class I18NTests(TestCase):
     14    """ Tests django views in django/views/i18n.py """
     15
     16    def test_setlang(self):
     17        """ Test set_language view """
     18        for lang_code, lang_name in settings.LANGUAGES:
     19            response = self.change_language(lang_code, '/django_views/')
     20            self.assertRedirects(response, 'http://testserver/django_views/')
     21            self.assertEquals(self.client.session['django_language'], lang_code)
     22
     23    def test_jsi18n(self):
     24        """ Test javascript_catalog view """
     25        for lang_code in ['es', 'fr', 'en']:
     26            activate(lang_code)
     27            locale_dir = path.join(path.dirname(__file__), 'locale')
     28            catalog = gettext.translation('djangojs', locale_dir, [lang_code])
     29            trans_txt = catalog.ugettext('this is to be translated')
     30            response = self.client.get('/django_views/jsi18n/')
     31            # in response content must to be a line like that:
     32            # catalog['this is to be translated'] = 'same_that_trans_txt'
     33            self.assertContains(response, trans_txt, 1)
     34
     35    def change_language(self, language, next):
     36        post_data = dict(language=language, next=next)
     37        return self.client.post('/django_views/i18n/setlang/', data=post_data)
  • tests/regressiontests/django_views/urls.py

     
     1from django.conf.urls.defaults import *
     2import views
     3
     4js_info_dict = {
     5    'domain': 'djangojs',
     6    'packages': ('regressiontests.django_views',),
     7}
     8
     9urlpatterns = patterns('',
     10    (r'^$', views.index_page),
     11    (r'^i18n/', include('django.conf.urls.i18n')),
     12    (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
     13    (r'^jsi18n_test/$', views.jsi18n_test),
     14)
  • tests/urls.py

     
    1111
    1212    # test urlconf for {% url %} template tag
    1313    (r'^url_tag/', include('regressiontests.templates.urls')),
     14   
     15    # django views tests urls
     16    (r'^django_views/', include('regressiontests.django_views.urls')),
    1417)
  • tests/runtests.py

     
    132132        except Exception, e:
    133133            sys.stderr.write("Error while importing %s:" % model_name + ''.join(traceback.format_exception(*sys.exc_info())[1:]))
    134134            continue
    135 
    136135    # Add tests for invalid models.
    137136    extra_tests = []
    138137    for model_dir, model_name in get_invalid_models():
  • tests/templates/js_i18n.html

     
     1{% extends "base.html" %}
     2{% load i18n %}
     3{% block title %}{% trans "Js Tests" %}{% endblock %}
     4{% block content %}
     5
     6{% endblock %}
  • AUTHORS

     
    257257    Brian Rosner <brosner@gmail.com>
    258258    Oliver Rutherfurd <http://rutherfurd.net/>
    259259    ryankanno
     260    Manuel Saelices <msaelices@yaco.es>
    260261    Ivan Sagalaev (Maniac) <http://www.softwaremaniacs.org/>
    261262    Vinay Sajip <vinay_sajip@yahoo.co.uk>
    262263    David Schein
Back to Top