Skip to content

Commit 4fc26a7

Browse files
committed
Test against pretty print
1 parent d44016d commit 4fc26a7

3 files changed

Lines changed: 72 additions & 0 deletions

File tree

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
site_name: Test RSS Plugin
2+
site_description: Test RSS Plugin
3+
4+
use_directory_urls: true
5+
6+
plugins:
7+
- search
8+
- rss:
9+
pretty_print: False
10+
11+
theme:
12+
name: mkdocs
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
site_name: Test RSS Plugin
2+
site_description: Test RSS Plugin
3+
4+
use_directory_urls: true
5+
6+
plugins:
7+
- search
8+
- rss:
9+
pretty_print: True
10+
11+
theme:
12+
name: mkdocs

tests/test_build.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,54 @@ def test_simple_build_item_length_unlimited(self):
262262
if feed_item.title not in ("Page without meta with short text",):
263263
self.assertGreaterEqual(len(feed_item.description), 150)
264264

265+
def test_simple_build_pretty_print_enabled(self):
266+
with tempfile.TemporaryDirectory() as tmpdirname:
267+
cli_result = self.build_docs_setup(
268+
testproject_path="docs",
269+
mkdocs_yml_filepath=Path(
270+
"tests/fixtures/mkdocs_pretty_print_enabled.yml"
271+
),
272+
output_path=tmpdirname,
273+
)
274+
if cli_result.exception is not None:
275+
e = cli_result.exception
276+
logger.debug(format_exception(type(e), e, e.__traceback__))
277+
278+
self.assertEqual(cli_result.exit_code, 0)
279+
self.assertIsNone(cli_result.exception)
280+
281+
# created items
282+
with Path(Path(tmpdirname) / "feed_rss_created.xml").open("r") as f:
283+
self.assertGreater(len(f.readlines()), 0)
284+
285+
# updated items
286+
with Path(Path(tmpdirname) / "feed_rss_updated.xml").open("r") as f:
287+
self.assertGreater(len(f.readlines()), 0)
288+
289+
def test_simple_build_pretty_print_disabled(self):
290+
with tempfile.TemporaryDirectory() as tmpdirname:
291+
cli_result = self.build_docs_setup(
292+
testproject_path="docs",
293+
mkdocs_yml_filepath=Path(
294+
"tests/fixtures/mkdocs_pretty_print_disabled.yml"
295+
),
296+
output_path=tmpdirname,
297+
)
298+
if cli_result.exception is not None:
299+
e = cli_result.exception
300+
logger.debug(format_exception(type(e), e, e.__traceback__))
301+
302+
self.assertEqual(cli_result.exit_code, 0)
303+
self.assertIsNone(cli_result.exception)
304+
305+
# created items
306+
with Path(Path(tmpdirname) / "feed_rss_created.xml").open("r") as f:
307+
self.assertEqual(len(f.readlines()), 1)
308+
309+
# updated items
310+
with Path(Path(tmpdirname) / "feed_rss_updated.xml").open("r") as f:
311+
self.assertEqual(len(f.readlines()), 1)
312+
265313
def test_rss_feed_validation(self):
266314
with tempfile.TemporaryDirectory() as tmpdirname:
267315
cli_result = self.build_docs_setup(

0 commit comments

Comments
 (0)