Ticket #5496: django_views_tests_r6360.diff
File django_views_tests_r6360.diff, 10.9 KB (added by , 17 years ago) |
---|
-
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 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 7 msgid "" 8 msgstr "" 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 msgid "this is to be translated" 20 msgstr "this is to be translated in english" -
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 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 7 msgid "" 8 msgstr "" 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 20 msgid "this is to be translated" 21 msgstr "esto tiene que ser traducido" -
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 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 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: 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 msgid "this is to be translated" 20 msgstr "il faut le traduire" -
regressiontests/django_views/views.py
1 from django.http import HttpResponse 2 from django.template import RequestContext 3 from django.shortcuts import render_to_response 4 5 6 def index_page(request): 7 """ Dummy index page """ 8 return HttpResponse('<html><body>Dummy page</body></html>') 9 10 11 def 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 -
regressiontests/django_views/fixtures/testdata.json
1 [ 2 { 3 "pk": 1, 4 "model": "django_views.article", 5 "fields": { 6 "author": 1, 7 "title": "Un articulo" 8 } 9 }, 10 { 11 "pk": 1, 12 "model": "django_views.author", 13 "fields": { 14 "name": "Amparo" 15 } 16 }, 17 { 18 "pk": 1, 19 "model": "sites.site", 20 "fields": { 21 "domain": "testserver", 22 "name": "testserver" 23 } 24 } 25 ] -
regressiontests/django_views/models.py
1 """ 2 Regression tests for Django Views 3 """ 4 5 from os import path 6 import gettext 7 8 from django.conf import settings 9 from django.http import Http404 10 from django.test import Client, TestCase 11 from django.contrib.sessions.models import Session 12 from django.contrib.contenttypes.models import ContentType 13 from django.utils.translation import activate 14 15 from django.db import models 16 from django.conf import settings 17 18 19 ########################## 20 # Models for testing 21 22 class Author(models.Model): 23 name = models.CharField(max_length=100) 24 25 def __unicode__(self): 26 return self.name 27 28 def get_absolute_url(self): 29 return '/django_views/authors/%s/' % self.id 30 31 32 class Article(models.Model): 33 title = models.CharField(max_length=100) 34 author = models.ForeignKey(Author) 35 36 def __unicode__(self): 37 return self.title 38 39 40 ########################## 41 # Tests suites 42 43 class DefaultsTests(TestCase): 44 fixtures = ['testdata.json'] 45 """ Test django views in django/views/defaults.py """ 46 47 def test_shorcut(self): 48 """ Test shorcut view """ 49 content_types = ContentType.objects.all() 50 for ct in content_types: 51 model = ct.model_class() 52 for obj in model.objects.all(): 53 short_url = '/django_views/r/%s/%s/' % (ct.id, obj.pk) 54 response = self.client.get(short_url) 55 if hasattr(obj, 'get_absolute_url'): 56 self.assertRedirects(response, 'http://testserver%s' % obj.get_absolute_url(), 57 target_status_code=404) 58 else: 59 self.assertEquals(response.status_code, 404) 60 61 def test_page_not_found(self): 62 non_existing_urls = ['/django_views/non_existing_url/', # this is in urls.py 63 '/django_views/other_non_existing_url/'] # this NOT in urls.py 64 for url in non_existing_urls: 65 response = self.client.get(url) 66 self.assertEquals(response.status_code, 404) 67 68 def test_server_error(self): 69 response = self.client.get('/django_views/server_error/') 70 self.assertEquals(response.status_code, 500) 71 72 73 class I18NTests(TestCase): 74 """ Tests django views in django/views/i18n.py """ 75 76 def test_setlang(self): 77 """ Test set_language view """ 78 for lang_code, lang_name in settings.LANGUAGES: 79 response = self.change_language(lang_code, '/django_views/') 80 self.assertRedirects(response, 'http://testserver/django_views/') 81 self.assertEquals(self.client.session['django_language'], lang_code) 82 83 def test_jsi18n(self): 84 """ Test javascript_catalog view """ 85 for lang_code in ['es', 'fr', 'en']: 86 activate(lang_code) 87 locale_dir = path.join(path.dirname(__file__), 'locale') 88 catalog = gettext.translation('djangojs', locale_dir, [lang_code]) 89 trans_txt = catalog.ugettext('this is to be translated') 90 response = self.client.get('/django_views/jsi18n/') 91 # in response content must to be a line like that: 92 # catalog['this is to be translated'] = 'same_that_trans_txt' 93 self.assertContains(response, trans_txt, 1) 94 95 def change_language(self, language, next): 96 post_data = dict(language=language, next=next) 97 return self.client.post('/django_views/i18n/setlang/', data=post_data) -
regressiontests/django_views/urls.py
1 from django.conf.urls.defaults import * 2 import views 3 4 js_info_dict = { 5 'domain': 'djangojs', 6 'packages': ('regressiontests.django_views',), 7 } 8 9 10 urlpatterns = patterns('', 11 (r'^$', views.index_page), 12 (r'^r/(\d+)/(.*)/$', 'django.views.defaults.shortcut'), 13 (r'^non_existing_url/', 'django.views.defaults.page_not_found'), 14 (r'^server_error/', 'django.views.defaults.server_error'), 15 (r'^i18n/', include('django.conf.urls.i18n')), 16 (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), 17 (r'^jsi18n_test/$', views.jsi18n_test), 18 ) -
urls.py
11 11 12 12 # test urlconf for {% url %} template tag 13 13 (r'^url_tag/', include('regressiontests.templates.urls')), 14 15 # django views tests urls 16 (r'^django_views/', include('regressiontests.django_views.urls')), 14 17 ) -
templates/js_i18n.html
1 {% extends "base.html" %} 2 {% load i18n %} 3 {% block title %}{% trans "Js Tests" %}{% endblock %} 4 {% block content %} 5 6 {% endblock %}