diff options
author | Marcelo Galigniana <marcelogaligniana@gmail.com> | 2022-05-22 18:15:11 -0300 |
---|---|---|
committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2022-05-23 06:16:26 +0200 |
commit | 241fe59b74bb6031fa644f3ad55e6ad6a9187510 (patch) | |
tree | 187c81d9b5b75965b60ac3118296e87642e23002 /tests/syndication_tests | |
parent | 1733c888f4928e91889e4ae5baf6badbd073e08c (diff) | |
download | django-241fe59b74bb6031fa644f3ad55e6ad6a9187510.tar.gz |
Refs #22078 -- Added syndication test for feeds with callable objects.
Diffstat (limited to 'tests/syndication_tests')
-rw-r--r-- | tests/syndication_tests/feeds.py | 8 | ||||
-rw-r--r-- | tests/syndication_tests/tests.py | 6 | ||||
-rw-r--r-- | tests/syndication_tests/urls.py | 3 |
3 files changed, 17 insertions, 0 deletions
diff --git a/tests/syndication_tests/feeds.py b/tests/syndication_tests/feeds.py index 17d807f302..f8c0a27832 100644 --- a/tests/syndication_tests/feeds.py +++ b/tests/syndication_tests/feeds.py @@ -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 diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index 464ca76d54..207ffb7bc8 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -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 diff --git a/tests/syndication_tests/urls.py b/tests/syndication_tests/urls.py index 511f977ebc..7ebcbf0e5b 100644 --- a/tests/syndication_tests/urls.py +++ b/tests/syndication_tests/urls.py @@ -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/", |