summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSimon Charette <charette.s@gmail.com>2013-02-06 05:25:35 -0500
committerSimon Charette <charette.s@gmail.com>2013-02-06 05:28:05 -0500
commit5449240c548bb6877923791d02e800c6b25393f5 (patch)
treee9b31639246e08efaaae21fdf7a1ac2a581ebee1 /tests
parent2390fe3f4f8f52e24157d79b0c60247207c9716f (diff)
Fixed #9800 -- Allow "isPermaLink" attribute in <guid> element of an RSS item.
Thanks @rtnpro for the patch!
Diffstat (limited to 'tests')
-rw-r--r--tests/regressiontests/syndication/feeds.py13
-rw-r--r--tests/regressiontests/syndication/tests.py36
-rw-r--r--tests/regressiontests/syndication/urls.py4
3 files changed, 52 insertions, 1 deletions
diff --git a/tests/regressiontests/syndication/feeds.py b/tests/regressiontests/syndication/feeds.py
index 04a67f4bdb..25757057b9 100644
--- a/tests/regressiontests/syndication/feeds.py
+++ b/tests/regressiontests/syndication/feeds.py
@@ -42,6 +42,19 @@ class TestRss2Feed(views.Feed):
item_copyright = 'Copyright (c) 2007, Sally Smith'
+class TestRss2FeedWithGuidIsPermaLinkTrue(TestRss2Feed):
+ def item_guid_is_permalink(self, item):
+ return True
+
+
+class TestRss2FeedWithGuidIsPermaLinkFalse(TestRss2Feed):
+ def item_guid(self, item):
+ return str(item.pk)
+
+ def item_guid_is_permalink(self, item):
+ return False
+
+
class TestRss091Feed(TestRss2Feed):
feed_type = feedgenerator.RssUserland091Feed
diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
index 10413b4ddd..8885dc28c0 100644
--- a/tests/regressiontests/syndication/tests.py
+++ b/tests/regressiontests/syndication/tests.py
@@ -103,9 +103,43 @@ class SyndicationFeedTest(FeedTestCase):
'author': 'test@example.com (Sally Smith)',
})
self.assertCategories(items[0], ['python', 'testing'])
-
for item in items:
self.assertChildNodes(item, ['title', 'link', 'description', 'guid', 'category', 'pubDate', 'author'])
+ # Assert that <guid> does not have any 'isPermaLink' attribute
+ self.assertIsNone(item.getElementsByTagName(
+ 'guid')[0].attributes.get('isPermaLink'))
+
+ def test_rss2_feed_guid_permalink_false(self):
+ """
+ Test if the 'isPermaLink' attribute of <guid> element of an item
+ in the RSS feed is 'false'.
+ """
+ response = self.client.get(
+ '/syndication/rss2/guid_ispermalink_false/')
+ doc = minidom.parseString(response.content)
+ chan = doc.getElementsByTagName(
+ 'rss')[0].getElementsByTagName('channel')[0]
+ items = chan.getElementsByTagName('item')
+ for item in items:
+ self.assertEqual(
+ item.getElementsByTagName('guid')[0].attributes.get(
+ 'isPermaLink').value, "false")
+
+ def test_rss2_feed_guid_permalink_true(self):
+ """
+ Test if the 'isPermaLink' attribute of <guid> element of an item
+ in the RSS feed is 'true'.
+ """
+ response = self.client.get(
+ '/syndication/rss2/guid_ispermalink_true/')
+ doc = minidom.parseString(response.content)
+ chan = doc.getElementsByTagName(
+ 'rss')[0].getElementsByTagName('channel')[0]
+ items = chan.getElementsByTagName('item')
+ for item in items:
+ self.assertEqual(
+ item.getElementsByTagName('guid')[0].attributes.get(
+ 'isPermaLink').value, "true")
def test_rss091_feed(self):
"""
diff --git a/tests/regressiontests/syndication/urls.py b/tests/regressiontests/syndication/urls.py
index 57f9d81a73..ec3c8cc596 100644
--- a/tests/regressiontests/syndication/urls.py
+++ b/tests/regressiontests/syndication/urls.py
@@ -8,6 +8,10 @@ from . import feeds
urlpatterns = patterns('django.contrib.syndication.views',
(r'^syndication/complex/(?P<foo>.*)/$', feeds.ComplexFeed()),
(r'^syndication/rss2/$', feeds.TestRss2Feed()),
+ (r'^syndication/rss2/guid_ispermalink_true/$',
+ feeds.TestRss2FeedWithGuidIsPermaLinkTrue()),
+ (r'^syndication/rss2/guid_ispermalink_false/$',
+ feeds.TestRss2FeedWithGuidIsPermaLinkFalse()),
(r'^syndication/rss091/$', feeds.TestRss091Feed()),
(r'^syndication/no_pubdate/$', feeds.TestNoPubdateFeed()),
(r'^syndication/atom/$', feeds.TestAtomFeed()),