mirror of https://github.com/django/django.git
Refs #22078 -- Added syndication test for feeds with callable objects.
This commit is contained in:
parent
1733c888f4
commit
241fe59b74
|
@ -39,6 +39,14 @@ class TestRss2Feed(views.Feed):
|
|||
item_copyright = "Copyright (c) 2007, Sally Smith"
|
||||
|
||||
|
||||
class TestRss2FeedWithCallableObject(TestRss2Feed):
|
||||
class TimeToLive:
|
||||
def __call__(self):
|
||||
return 700
|
||||
|
||||
ttl = TimeToLive()
|
||||
|
||||
|
||||
class TestRss2FeedWithGuidIsPermaLinkTrue(TestRss2Feed):
|
||||
def item_guid_is_permalink(self, item):
|
||||
return True
|
||||
|
|
|
@ -196,6 +196,12 @@ class SyndicationFeedTest(FeedTestCase):
|
|||
item.getElementsByTagName("guid")[0].attributes.get("isPermaLink")
|
||||
)
|
||||
|
||||
def test_rss2_feed_with_callable_object(self):
|
||||
response = self.client.get("/syndication/rss2/with-callable-object/")
|
||||
doc = minidom.parseString(response.content)
|
||||
chan = doc.getElementsByTagName("rss")[0].getElementsByTagName("channel")[0]
|
||||
self.assertChildNodeContent(chan, {"ttl": "700"})
|
||||
|
||||
def test_rss2_feed_guid_permalink_false(self):
|
||||
"""
|
||||
Test if the 'isPermaLink' attribute of <guid> element of an item
|
||||
|
|
|
@ -4,6 +4,9 @@ from . import feeds
|
|||
|
||||
urlpatterns = [
|
||||
path("syndication/rss2/", feeds.TestRss2Feed()),
|
||||
path(
|
||||
"syndication/rss2/with-callable-object/", feeds.TestRss2FeedWithCallableObject()
|
||||
),
|
||||
path("syndication/rss2/articles/<int:entry_id>/", feeds.TestGetObjectFeed()),
|
||||
path(
|
||||
"syndication/rss2/guid_ispermalink_true/",
|
||||
|
|
Loading…
Reference in New Issue