From 0210dbcbe3ee7fc84e25efbec256adbec36ea9ff Mon Sep 17 00:00:00 2001 From: Marcelo Galigniana Date: Mon, 2 May 2022 00:20:00 -0300 Subject: [4.1.x] Fixed #22078 -- Fixed crash of Feed with decorated methods. Backport of 8c0886b068ba4e224dd78104b93c9638b860b398 from main. --- tests/syndication_tests/tests.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'tests/syndication_tests/tests.py') diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py index b5338738e5..dc4232e61d 100644 --- a/tests/syndication_tests/tests.py +++ b/tests/syndication_tests/tests.py @@ -196,11 +196,38 @@ class SyndicationFeedTest(FeedTestCase): item.getElementsByTagName("guid")[0].attributes.get("isPermaLink") ) - def test_rss2_feed_with_static_methods(self): - response = self.client.get("/syndication/rss2/with-static-methods/") + def test_rss2_feed_with_decorated_methods(self): + response = self.client.get("/syndication/rss2/with-decorated-methods/") doc = minidom.parseString(response.content) chan = doc.getElementsByTagName("rss")[0].getElementsByTagName("channel")[0] self.assertCategories(chan, ["javascript", "vue"]) + self.assertChildNodeContent( + chan, + { + "title": "Overridden title -- decorated by @wraps.", + "description": "Overridden description -- decorated by @wraps.", + "ttl": "800 -- decorated by @wraps.", + "copyright": "Copyright (c) 2022, John Doe -- decorated by @wraps.", + }, + ) + items = chan.getElementsByTagName("item") + self.assertChildNodeContent( + items[0], + { + "title": ( + f"Overridden item title: {self.e1.title} -- decorated by @wraps." + ), + "description": "Overridden item description -- decorated by @wraps.", + }, + ) + + def test_rss2_feed_with_wrong_decorated_methods(self): + msg = ( + "Feed method 'item_description' decorated by 'wrapper' needs to use " + "@functools.wraps." + ) + with self.assertRaisesMessage(ImproperlyConfigured, msg): + self.client.get("/syndication/rss2/with-wrong-decorated-methods/") def test_rss2_feed_guid_permalink_false(self): """ -- cgit v1.3