Skip to content

Commit

Permalink
Add complete config
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Mar 30, 2022
1 parent c4b3649 commit b5845d9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
3 changes: 2 additions & 1 deletion tests/fixtures/docs/page_with_meta.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
---
title: Use the MkDocs RSS Plugin
title: Use the MkDocs RSS Plugin with confidence
authors:
- Guts
- Tim Vink
- liang2kl
date: 2020-03-20 10:20
description: First test page of mkdocs-rss-plugin test suite
image: "https://svgsilh.com/png-512/97849.png"
tags:
- test
---
Expand Down
21 changes: 17 additions & 4 deletions tests/fixtures/mkdocs_complete.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,24 @@ use_directory_urls: true

plugins:
- rss:
abstract_chars_count: 200
abstract_chars_count: 160 # -1 for full content
categories:
- tags
comments_path: "#__comments"
feed_ttl: 90
length: 3

date_from_meta:
as_creation: "date"
as_update: false
datetime_format: "%Y-%m-%d %H:%M"
enabled: true
feed_ttl: 1440
image: https://upload.wikimedia.org/wikipedia/commons/thumb/4/43/Feed-icon.svg/128px-Feed-icon.svg.png
length: 20
pretty_print: false
match_path: ".*"
url_parameters:
utm_source: "documentation"
utm_medium: "RSS"
utm_campaign: "feed-syndication"
theme:
name: readthedocs

Expand Down
42 changes: 42 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,48 @@ def test_simple_build_minimal(self):
if feed_item.title in ("Test page with meta",):
self.assertTrue("author" in feed_item)

def test_simple_build_complete(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
testproject_path="docs",
mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_complete.yml"),
output_path=tmpdirname,
strict=True,
)

if cli_result.exception is not None:
e = cli_result.exception
logger.debug(format_exception(type(e), e, e.__traceback__))

self.assertEqual(cli_result.exit_code, 0)
self.assertIsNone(cli_result.exception)

# created items
feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml")
for feed_item in feed_parsed.entries:

# mandatory properties
self.assertTrue("description" in feed_item)
self.assertTrue("guid" in feed_item)
self.assertTrue("link" in feed_item)
self.assertTrue("published" in feed_item)
self.assertTrue("source" in feed_item)
self.assertTrue("title" in feed_item)

# optional - following should not be present in the feed by default
if (
"without_meta" in feed_item.title
or feed_item.title == "Test home page"
):
self.assertTrue("category" not in feed_item)
self.assertTrue("comments" in feed_item)
elif "with_meta" in feed_item.title:
self.assertTrue("author" in feed_item)
self.assertTrue("category" in feed_item)
self.assertTrue("enclosure" in feed_item)
else:
pass

def test_simple_build_disabled(self):
with tempfile.TemporaryDirectory() as tmpdirname:
cli_result = self.build_docs_setup(
Expand Down

0 comments on commit b5845d9

Please sign in to comment.