From cda78271e9ba9106895c29f520e59398226daa70 Mon Sep 17 00:00:00 2001 From: Rob Taylor Date: Wed, 16 Oct 2024 23:48:49 +0100 Subject: [PATCH] coverage: Test `publish --no-toc` feature --- doorstop/cli/tests/test_all.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/doorstop/cli/tests/test_all.py b/doorstop/cli/tests/test_all.py index 7b6d046a..93f0e42d 100644 --- a/doorstop/cli/tests/test_all.py +++ b/doorstop/cli/tests/test_all.py @@ -796,6 +796,23 @@ def test_publish_document_html_file(self): filePath = os.path.join(self.temp, "documents", "req.html") self.assertTrue(os.path.isfile(filePath)) + def test_publish_document_md_file_no_toc(self): + """Verify 'doorstop publish --no-toc' creates an MarkDownfile with no TOC.""" + path = os.path.join(self.temp, "req.md") + self.assertIs(None, main(["publish", "--no-toc", "req", path])) + self.assertTrue(os.path.isfile(path)) + text = common.read_text(path) + self.assertNotIn("Table of Contents", text) + + def test_publish_document_html_file_no_toc(self): + """Verify 'doorstop publish --no-toc' creates an HTML file with no TOC.""" + path = os.path.join(self.temp, "req.html") + self.assertIs(None, main(["publish", "--no-toc", "req", path])) + filePath = os.path.join(self.temp, "documents", "req.html") + self.assertTrue(os.path.isfile(filePath)) + text = common.read_text(filePath) + self.assertNotIn("Table of Contents", text) + def test_publish_tree_html(self): """Verify 'doorstop publish' can create an HTML directory.""" path = os.path.join(self.temp, "all") @@ -842,6 +859,13 @@ def test_publish_markdown_tree_no_path(self): ], ) + def test_publish_tree_html_no_toc(self): + """Verify 'doorstop publish --no-toc' returns a html document with no toc.""" + path = os.path.join(self.temp, "all") + self.assertIs(None, main(["publish", "--no-toc", "all", path])) + self.assertTrue(os.path.isdir(path)) + self.assertTrue(os.path.isfile(os.path.join(path, "index.html"))) + class TestPublishCommand(TempTestCase): """Tests 'doorstop publish' options toc and template"""