Ticket #13881: 13881.tests.patch

File 13881.tests.patch, 2.6 KB (added by Gregor Müllegger, 14 years ago)

Creating regressiontestmodule for sitemaps application and failing tests for the descriptions in the ticket.

  • tests/regressiontests/sitemaps/__init__.py

    === added directory 'tests/regressiontests/sitemaps'
    === added file 'tests/regressiontests/sitemaps/__init__.py'
     
     1# empty.
  • tests/regressiontests/sitemaps/models.py

    === added file 'tests/regressiontests/sitemaps/models.py'
     
     1# empty.
  • tests/regressiontests/sitemaps/tests.py

    === added file 'tests/regressiontests/sitemaps/tests.py'
     
     1# -*- coding: utf-8 -*-
     2from datetime import datetime
     3from django.conf import settings
     4from django.utils import translation
     5from django.test import TestCase
     6from django.contrib.sitemaps import Sitemap
     7
     8
     9class Page(object):
     10    def get_absolute_url(self):
     11        return '/'
     12
     13
     14class PageSitemap(Sitemap):
     15    changefreq = 'weekly'
     16    priority = 0.5
     17
     18    def items(self):
     19        return [Page(), Page(), Page()]
     20
     21    def lastmod(self, obj):
     22        return datetime.now()
     23
     24
     25class TestSitemap(TestCase):
     26    urls = 'regressiontests.sitemaps.urls'
     27
     28    def test_localized_priority(self):
     29        '''
     30        Issue 13881: Priority's decimal separator is localized but shouldn't.
     31        '''
     32        org_l10n, settings.USE_L10N = settings.USE_L10N, True
     33        org_lang = translation.get_language()
     34        settings.INSTALLED_APPS += ('django.contrib.sitemaps',)
     35        try:
     36            translation.activate('ru')
     37            sitemap = PageSitemap()
     38            response = self.client.get('/sitemap-page.xml')
     39            self.assertNotContains(response, '<priority>0,5</priority>')
     40            self.assertContains(response, '<priority>0.5</priority>')
     41        finally:
     42            settings.L10N = org_l10n
     43            settings.INSTALLED_APPS = settings.INSTALLED_APPS[:-1]
     44            translation.activate(org_lang)
  • tests/regressiontests/sitemaps/urls.py

    === added file 'tests/regressiontests/sitemaps/urls.py'
     
     1from django.conf.urls.defaults import handler404, handler500, patterns, url
     2from regressiontests.sitemaps.tests import PageSitemap
     3
     4sitemaps = {
     5    'page': PageSitemap(),
     6}
     7
     8urlpatterns = patterns('django.contrib.sitemaps.views',
     9    url(r'^sitemap-(?P<section>\w+).xml$', 'sitemap', {'sitemaps': sitemaps}),
     10)
Back to Top