Skip to content

Commit

Permalink
Test against pretty print
Browse files Browse the repository at this point in the history
  • Loading branch information
Guts committed Mar 29, 2022
1 parent d44016d commit 4fc26a7
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/fixtures/mkdocs_pretty_print_disabled.yml
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/fixtures/mkdocs_pretty_print_enabled.yml
Original file line number Diff line number Diff line change
@@ -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
48 changes: 48 additions & 0 deletions tests/test_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4fc26a7

Please sign in to comment.