summaryrefslogtreecommitdiff
path: root/tests/regressiontests/syndication/tests.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/regressiontests/syndication/tests.py')
-rw-r--r--tests/regressiontests/syndication/tests.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
index 1410ed7517..816cb44675 100644
--- a/tests/regressiontests/syndication/tests.py
+++ b/tests/regressiontests/syndication/tests.py
@@ -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') \ No newline at end of file
+ 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')
+ \ No newline at end of file