Ticket #14164: 14164_l10n_sitemaps.diff
File 14164_l10n_sitemaps.diff, 3.9 KB (added by , 14 years ago) |
---|
-
django/contrib/sitemaps/__init__.py
69 69 'location': loc, 70 70 'lastmod': self.__get('lastmod', item, None), 71 71 'changefreq': self.__get('changefreq', item, None), 72 'priority': s elf.__get('priority', item, None)72 'priority': str(self.__get('priority', item, '')) 73 73 } 74 74 urls.append(url_info) 75 75 return urls -
tests/regressiontests/sitemaps/tests.py
1 from xml.dom.minidom import parseString 2 3 from django.conf import settings 4 from django.test import TestCase 5 from django.utils.formats import localize 6 from django.utils.translation import activate 7 8 9 class LocalizationTests(TestCase): 10 11 def setUp(self): 12 self.orig_use_l10n = settings.USE_L10N 13 14 def tearDown(self): 15 settings.USE_L10N = self.orig_use_l10n 16 17 def test_localized_priority(self): 18 """The priority value should not be localized (#14164)""" 19 settings.USE_L10N = True 20 activate('fr') 21 # Localization should be active now: 22 self.assertEqual(u'0,3', localize(0.3)) 23 # Retrieve an item with a known priority and check it: 24 response = self.client.get('/sitemaps/sitemap.xml') 25 doc = parseString(response.content) 26 priority = None 27 for elt in doc.getElementsByTagName('url'): 28 loc = elt.childNodes[0].childNodes[0].nodeValue 29 if loc.endswith('/ticket14164'): 30 priority = elt.childNodes[3].childNodes[0].nodeValue 31 break 32 self.assertEqual(u'0.5', priority) -
tests/regressiontests/sitemaps/urls.py
1 from django.conf.urls.defaults import * 2 3 from sitemaps import SimpleSitemap 4 5 6 sitemaps = { 7 'simple': SimpleSitemap, 8 } 9 10 11 urlpatterns = patterns('django.contrib.sitemaps.views', 12 (r'^sitemap\.xml$', 'sitemap', {'sitemaps': sitemaps}), 13 ) -
tests/regressiontests/sitemaps/sitemaps.py
1 from datetime import datetime 2 from django.contrib.sitemaps import Sitemap 3 4 5 class SimpleSitemap(Sitemap): 6 changefreq = "never" 7 priority = 0.5 8 location = '/ticket14164' 9 lastmod = datetime.now() 10 11 def items(self): 12 return [object()] -
tests/urls.py
41 41 42 42 # special headers views 43 43 (r'special_headers/', include('regressiontests.special_headers.urls')), 44 45 # sitemaps 46 (r'^sitemaps/', include('regressiontests.sitemaps.urls')), 44 47 ) -
tests/runtests.py
28 28 'django.contrib.comments', 29 29 'django.contrib.admin', 30 30 'django.contrib.admindocs', 31 'django.contrib.sitemaps', 31 32 ] 32 33 33 34 def get_test_models():