summaryrefslogtreecommitdiff
path: root/tests_feedgenerator
diff options
context:
space:
mode:
authorBastian Venthur <venthur@debian.org>2021-09-27 21:04:49 +0200
committerJustin Mayer <entroP@gmail.com>2021-09-28 12:53:48 +0200
commitbfe94997048d72d289835c9df236387e9a48fd5f (patch)
treed1fac367c129255fbc784f9fc1d8410954ecb9d4 /tests_feedgenerator
parentf438a4b6eab6714d1738c16e1c19a027768d3b16 (diff)
downloadfeedgenerator-bfe94997048d72d289835c9df236387e9a48fd5f.tar.gz
Fix double subtitles if description & subtitle are provided
Tests all four possible combinations against the expected result.
Diffstat (limited to 'tests_feedgenerator')
-rw-r--r--tests_feedgenerator/test_feedgenerator.py49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests_feedgenerator/test_feedgenerator.py b/tests_feedgenerator/test_feedgenerator.py
index 6ec28aa..7370954 100644
--- a/tests_feedgenerator/test_feedgenerator.py
+++ b/tests_feedgenerator/test_feedgenerator.py
@@ -96,3 +96,52 @@ class TestFeedGenerator(unittest.TestCase):
expected_result = build_expected_atom_result(feed, EXPECTED_RESULT_ATOM, None)
self.assertEqual(type(result), type(expected_result))
self.assertEqual(result, expected_result)
+
+ def test_subtitle(self):
+ """Test regression for https://github.com/getpelican/feedgenerator/issues/30.
+
+ """
+ # case 1: neither should be in
+ FIXT_FEED = dict(
+ title="title",
+ link="https://example.com",
+ description=None,
+ subtitle=None,
+ )
+ feed = feedgenerator.Atom1Feed(**FIXT_FEED)
+ result = feed.writeString(ENCODING)
+ assert "<desciption></description>" not in result
+
+ # case 2: only description should be in
+ FIXT_FEED = dict(
+ title="title",
+ link="https://example.com",
+ description="description",
+ subtitle=None,
+ )
+ feed = feedgenerator.Atom1Feed(**FIXT_FEED)
+ result = feed.writeString(ENCODING)
+ assert "<subtitle>description</subtitle>" in result
+
+ # case 3: only subtitle should be in
+ FIXT_FEED = dict(
+ title="title",
+ link="https://example.com",
+ description=None,
+ subtitle="subtitle",
+ )
+ feed = feedgenerator.Atom1Feed(**FIXT_FEED)
+ result = feed.writeString(ENCODING)
+ assert "<subtitle>subtitle</subtitle>" in result
+
+ # case 4: both are in, only subtitle should be in
+ FIXT_FEED = dict(
+ title="title",
+ link="https://example.com",
+ description="description",
+ subtitle="subtitle",
+ )
+ feed = feedgenerator.Atom1Feed(**FIXT_FEED)
+ result = feed.writeString(ENCODING)
+ assert "<subtitle>subtitle</subtitle>" in result
+ assert "<subtitle>description</subtitle>" not in result