mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
[4.1.x] Fixed #22078 -- Fixed crash of Feed with decorated methods.
Backport of 8c0886b068 from main.
This commit is contained in:
committed by
Mariusz Felisiak
parent
9d3b812001
commit
0210dbcbe3
@@ -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):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user