diff --git a/tests/fixtures/docs/page_with_meta.md b/tests/fixtures/docs/page_with_meta.md index 4fa8f3d8..9d6e6d25 100644 --- a/tests/fixtures/docs/page_with_meta.md +++ b/tests/fixtures/docs/page_with_meta.md @@ -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 --- diff --git a/tests/fixtures/mkdocs_complete.yml b/tests/fixtures/mkdocs_complete.yml index a5f01b2e..74974a65 100644 --- a/tests/fixtures/mkdocs_complete.yml +++ b/tests/fixtures/mkdocs_complete.yml @@ -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 diff --git a/tests/test_build.py b/tests/test_build.py index e4f7cbca..5e75f324 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -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(