Skip to content

Commit 1c23924

Browse files
committed
chore: add tests for per-page rss.feed_description
1 parent 0f9806a commit 1c23924

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: Page with overridden rss feed description
3+
authors:
4+
- Guts
5+
- Tim Vink
6+
- liang2kl
7+
date: 2020-03-20 10:20
8+
update: 2022-03-30 10:20
9+
description: First test page of mkdocs-rss-plugin test suite
10+
image: "https://svgsilh.com/png-512/97849.png"
11+
rss:
12+
feed_description: This is a custom override of the feed description
13+
tags:
14+
- test
15+
---
16+
17+
# Test page with meta
18+
19+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

tests/test_build.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,40 @@ def test_simple_build_custom_title_description(self):
679679
self.assertEqual(feed_parsed.feed.title, "My custom RSS title")
680680
self.assertEqual(feed_parsed.feed.description, "My custom RSS description")
681681

682+
def test_simple_build_override_per_page_rss_feed_description(self):
683+
"""
684+
Test per-page rss.feed_description overrides the config site_description and rss.feed_description
685+
686+
How to run this test:
687+
pytest tests/test_build.py::TestBuildRss::test_simple_build_override_per_page_rss_feed_description
688+
"""
689+
with tempfile.TemporaryDirectory() as tmpdirname:
690+
cli_result = self.build_docs_setup(
691+
testproject_path="docs",
692+
mkdocs_yml_filepath=Path(
693+
"tests/fixtures/mkdocs_custom_title_description.yml"
694+
),
695+
output_path=tmpdirname,
696+
)
697+
if cli_result.exception is not None:
698+
e = cli_result.exception
699+
logger.debug(format_exception(type(e), e, e.__traceback__))
700+
701+
self.assertEqual(cli_result.exit_code, 0)
702+
self.assertIsNone(cli_result.exception)
703+
704+
# created items
705+
feed_parsed = feedparser.parse(Path(tmpdirname) / OUTPUT_RSS_FEED_CREATED)
706+
for feed_item in feed_parsed.entries:
707+
if feed_item.title == "Page with overridden rss feed description":
708+
self.assertEqual(
709+
feed_item.description,
710+
"This is a custom override of the feed description",
711+
)
712+
break
713+
else:
714+
self.fail("Page with overridden rss feed description not found")
715+
682716
def test_rss_feed_validation(self):
683717
with tempfile.TemporaryDirectory() as tmpdirname:
684718
cli_result = self.build_docs_setup(

0 commit comments

Comments
 (0)