summaryrefslogtreecommitdiff
path: root/tests/syndication_tests/tests.py
diff options
context:
space:
mode:
authorMarcelo Galigniana <marcelogaligniana@gmail.com>2022-05-02 00:20:00 -0300
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2022-05-26 11:13:42 +0200
commit0210dbcbe3ee7fc84e25efbec256adbec36ea9ff (patch)
treef298062ddf2c92cf0bd4002a2d0422ab650bf17b /tests/syndication_tests/tests.py
parent9d3b812001ee0457946865ef13f6192faed6bf73 (diff)
[4.1.x] Fixed #22078 -- Fixed crash of Feed with decorated methods.
Backport of 8c0886b068ba4e224dd78104b93c9638b860b398 from main.
Diffstat (limited to 'tests/syndication_tests/tests.py')
-rw-r--r--tests/syndication_tests/tests.py31
1 files changed, 29 insertions, 2 deletions
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):
"""