Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Release type: patch

Restore missing `content` property to default item dictionary.
2 changes: 2 additions & 0 deletions feedgenerator/django/utils/feedgenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def add_item(
categories=(),
item_copyright=None,
ttl=None,
content=None,
updateddate=None,
enclosures=None,
**kwargs,
Expand All @@ -197,6 +198,7 @@ def to_str(s):
"title": to_str(title),
"link": iri_to_uri(link),
"description": to_str(description),
"content": to_str(content),
"author_email": to_str(author_email),
"author_name": to_str(author_name),
"author_link": iri_to_uri(author_link),
Expand Down
70 changes: 70 additions & 0 deletions tests/test_feedgenerator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime
from urllib.parse import quote
from zoneinfo import ZoneInfo

import pytest
Expand Down Expand Up @@ -27,6 +28,9 @@
pubdate=NAIVE_DATE,
)

MINIMAL_FEED = {key: FIXT_FEED[key] for key in ("title", "link", "description")}
MINIMAL_ITEM = {key: FIXT_ITEM[key] for key in ("title", "link", "description")}


EXPECTED_RESULT_RSS = """<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Poynter E-Media Tidbits</title><link>http://www.poynter.org/column.asp?id=31</link><description>A group Weblog by the sharpest minds in online media/journalism/publishing.
Expand Down Expand Up @@ -162,3 +166,69 @@ def test_timezone_handling(generator, date, expected_date_string):
result = feed.writeString(ENCODING)

assert expected_date_string in result


def test_feed_default_properties():
feed = feedgenerator.SyndicationFeed(**MINIMAL_FEED)

for key in ("title", "link", "description"):
assert feed.feed[key] == MINIMAL_FEED[key]

for key in (
"language",
"author_email",
"author_name",
"author_link",
"subtitle",
"categories",
"feed_url",
"feed_copyright",
"id",
"ttl",
"stylesheets",
):
assert key in feed.feed

# Testing this after testing that the property exists
assert feed.feed["id"] == MINIMAL_FEED["link"]


def test_item_default_properties():
feed = feedgenerator.SyndicationFeed(**MINIMAL_FEED)
feed.add_item(**MINIMAL_ITEM)

for key in ("title", "description"):
expected_value = MINIMAL_ITEM[key]
# The link in the test contains a multibyte character
if key == "link":
expected_value = quote(MINIMAL_ITEM[key], safe="/#%[]=:;$&()+,!?*@'~")
assert feed.items[0][key] == expected_value

for key in (
"content",
"author_email",
"author_name",
"author_link",
"pubdate",
"updateddate",
"comments",
"unique_id",
"unique_id_is_permalink",
"enclosures",
"categories",
"item_copyright",
"ttl",
):
assert key in feed.items[0]


def test_feed_kwargs():
feed = feedgenerator.SyndicationFeed(test="test", **FIXT_FEED)
assert "test" in feed.feed


def test_item_kwargs():
feed = feedgenerator.SyndicationFeed(**FIXT_ITEM)
feed.add_item(test="test", **FIXT_ITEM)

assert "test" in feed.items[0]
Loading