mirror of
https://github.com/django/django.git
synced 2025-10-25 06:36:07 +00:00
Fixed #9957: feeds now respect time zone information provided by the pub date.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@10435 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import datetime
|
||||
from xml.dom import minidom
|
||||
from django.test import TestCase
|
||||
from django.test.client import Client
|
||||
from django.utils import tzinfo
|
||||
from models import Entry
|
||||
try:
|
||||
set
|
||||
@@ -91,4 +93,27 @@ class SyndicationFeedTest(TestCase):
|
||||
link = item.getElementsByTagName('link')[0]
|
||||
if link.firstChild.wholeText == 'http://example.com/blog/4/':
|
||||
title = item.getElementsByTagName('title')[0]
|
||||
self.assertEquals(title.firstChild.wholeText, u'A & B < C > D')
|
||||
self.assertEquals(title.firstChild.wholeText, u'A & B < C > D')
|
||||
|
||||
def test_naive_datetime_conversion(self):
|
||||
"""
|
||||
Test that datetimes are correctly converted to the local time zone.
|
||||
"""
|
||||
# Naive date times passed in get converted to the local time zone, so
|
||||
# check the recived zone offset against the local offset.
|
||||
response = self.client.get('/syndication/feeds/naive-dates/')
|
||||
doc = minidom.parseString(response.content)
|
||||
updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText
|
||||
tz = tzinfo.LocalTimezone(datetime.datetime.now())
|
||||
now = datetime.datetime.now(tz)
|
||||
self.assertEqual(updated[-6:], str(now)[-6:])
|
||||
|
||||
def test_aware_datetime_conversion(self):
|
||||
"""
|
||||
Test that datetimes with timezones don't get trodden on.
|
||||
"""
|
||||
response = self.client.get('/syndication/feeds/aware-dates/')
|
||||
doc = minidom.parseString(response.content)
|
||||
updated = doc.getElementsByTagName('updated')[0].firstChild.wholeText
|
||||
self.assertEqual(updated[-6:], '+00:42')
|
||||
|
||||
Reference in New Issue
Block a user