From 4fc26a76f9ee306b58e3ec7da0489b10f9430222 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Tue, 29 Mar 2022 19:42:17 +0200 Subject: [PATCH] Test against pretty print --- .../fixtures/mkdocs_pretty_print_disabled.yml | 12 +++++ .../fixtures/mkdocs_pretty_print_enabled.yml | 12 +++++ tests/test_build.py | 48 +++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 tests/fixtures/mkdocs_pretty_print_disabled.yml create mode 100644 tests/fixtures/mkdocs_pretty_print_enabled.yml diff --git a/tests/fixtures/mkdocs_pretty_print_disabled.yml b/tests/fixtures/mkdocs_pretty_print_disabled.yml new file mode 100644 index 00000000..00758578 --- /dev/null +++ b/tests/fixtures/mkdocs_pretty_print_disabled.yml @@ -0,0 +1,12 @@ +site_name: Test RSS Plugin +site_description: Test RSS Plugin + +use_directory_urls: true + +plugins: + - search + - rss: + pretty_print: False + +theme: + name: mkdocs diff --git a/tests/fixtures/mkdocs_pretty_print_enabled.yml b/tests/fixtures/mkdocs_pretty_print_enabled.yml new file mode 100644 index 00000000..31c60c6e --- /dev/null +++ b/tests/fixtures/mkdocs_pretty_print_enabled.yml @@ -0,0 +1,12 @@ +site_name: Test RSS Plugin +site_description: Test RSS Plugin + +use_directory_urls: true + +plugins: + - search + - rss: + pretty_print: True + +theme: + name: mkdocs diff --git a/tests/test_build.py b/tests/test_build.py index dc9934e2..01623e00 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -262,6 +262,54 @@ def test_simple_build_item_length_unlimited(self): if feed_item.title not in ("Page without meta with short text",): self.assertGreaterEqual(len(feed_item.description), 150) + def test_simple_build_pretty_print_enabled(self): + with tempfile.TemporaryDirectory() as tmpdirname: + cli_result = self.build_docs_setup( + testproject_path="docs", + mkdocs_yml_filepath=Path( + "tests/fixtures/mkdocs_pretty_print_enabled.yml" + ), + output_path=tmpdirname, + ) + 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 + with Path(Path(tmpdirname) / "feed_rss_created.xml").open("r") as f: + self.assertGreater(len(f.readlines()), 0) + + # updated items + with Path(Path(tmpdirname) / "feed_rss_updated.xml").open("r") as f: + self.assertGreater(len(f.readlines()), 0) + + def test_simple_build_pretty_print_disabled(self): + with tempfile.TemporaryDirectory() as tmpdirname: + cli_result = self.build_docs_setup( + testproject_path="docs", + mkdocs_yml_filepath=Path( + "tests/fixtures/mkdocs_pretty_print_disabled.yml" + ), + output_path=tmpdirname, + ) + 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 + with Path(Path(tmpdirname) / "feed_rss_created.xml").open("r") as f: + self.assertEqual(len(f.readlines()), 1) + + # updated items + with Path(Path(tmpdirname) / "feed_rss_updated.xml").open("r") as f: + self.assertEqual(len(f.readlines()), 1) + def test_rss_feed_validation(self): with tempfile.TemporaryDirectory() as tmpdirname: cli_result = self.build_docs_setup(