From dd71dd17df37fd76535381ed95981fbc32af1819 Mon Sep 17 00:00:00 2001 From: GeoJulien Date: Wed, 30 Mar 2022 22:24:15 +0200 Subject: [PATCH] Test bad date format --- tests/test_build.py | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/test_build.py b/tests/test_build.py index 81bbeb8b..a13e8748 100644 --- a/tests/test_build.py +++ b/tests/test_build.py @@ -188,12 +188,6 @@ def test_simple_build_item_dates(self): self.assertEqual(cli_result.exit_code, 0) self.assertIsNone(cli_result.exception) - # created items - feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_created.xml") - - # updated items - feed_parsed = feedparser.parse(Path(tmpdirname) / "feed_rss_updated.xml") - def test_simple_build_feed_length(self): with tempfile.TemporaryDirectory() as tmpdirname: cli_result = self.build_docs_setup( @@ -411,7 +405,7 @@ def test_bad_config(self): with tempfile.TemporaryDirectory() as tmpdirname: cli_result = self.build_docs_setup( testproject_path="docs", - mkdocs_yml_filepath=Path("mkdocs_bad_config.yml"), + mkdocs_yml_filepath=Path("tests/fixtures/mkdocs_bad_config.yml"), output_path=tmpdirname, strict=True, ) @@ -420,6 +414,29 @@ def test_bad_config(self): self.assertEqual(cli_result.exit_code, 2) self.assertIsNotNone(cli_result.exception) + def test_bad_date_format(self): + # add a new page without tracking it + md_str = """---\ndate: 13 April 2022\n---\n\n# This page is dynamically created for test purposes\n\nHi!\n + """ + temp_page = Path("tests/fixtures/docs/temp_page_not_in_git_log.md") + if temp_page.exists(): + temp_page.unlink() + temp_page.write_text(md_str) + + with tempfile.TemporaryDirectory() as tmpdirname: + cli_result = self.build_docs_setup( + testproject_path="docs", + mkdocs_yml_filepath=Path("mkdocs.yml"), + output_path=tmpdirname, + strict=True, + ) + + self.assertEqual(cli_result.exit_code, 0) + self.assertIsNone(cli_result.exception) + + # rm page + temp_page.unlink() + def test_not_in_git_log(self): # add a new page without tracking it md_str = """# This page is dynamically created for test purposes\n\nHi!\n