From 3a0e4c821de5d5c3a1885d22a7a2faccb091947b Mon Sep 17 00:00:00 2001 From: Rob Taylor Date: Thu, 3 Oct 2024 16:42:59 -0400 Subject: [PATCH] Mock plantuml execution --- doorstop/core/tests/files/published.html | 17 ++++++++++++++++- doorstop/core/tests/files/published2.html | 17 ++++++++++++++++- doorstop/core/tests/test_all.py | 23 +++++++++++++++++++++-- 3 files changed, 53 insertions(+), 4 deletions(-) diff --git a/doorstop/core/tests/files/published.html b/doorstop/core/tests/files/published.html index 3fdbe718f..081b52931 100644 --- a/doorstop/core/tests/files/published.html +++ b/doorstop/core/tests/files/published.html @@ -105,7 +105,22 @@

1.6 REQ004

Hello, world!

2.1 Plantuml REQ002

Hello, world!

-

AuthorCreate DocumentCreate ItemLink Item to DocumentLink Item to other ItemEdit ItemReview ItemDelete ItemDelete DocumentExportImportReviewerSystemSuspect ChangesIntegrity

+

plantuml format="svg_inline" alt="Use Cases of Doorstop" title="Use Cases of Doorstop" +@startuml +Author --> (Create Document) +Author --> (Create Item) +Author --> (Link Item to Document) +Author --> (Link Item to other Item) +Author --> (Edit Item) +Author --> (Review Item) +Author -> (Delete Item) +Author -> (Delete Document) +(Export) <- (Author) +(Import) <- (Author) +Reviewer --> (Review Item) +System --> (Suspect Changes) +System --> (Integrity) +@enduml

Child links: TST001, TST002

2.1 REQ2-001

Hello, world!

diff --git a/doorstop/core/tests/files/published2.html b/doorstop/core/tests/files/published2.html index ecc2a319f..f1c1435d5 100644 --- a/doorstop/core/tests/files/published2.html +++ b/doorstop/core/tests/files/published2.html @@ -105,7 +105,22 @@

1.6 REQ004

Hello, world!

2.1 Plantuml REQ002

Hello, world!

-

AuthorCreate DocumentCreate ItemLink Item to DocumentLink Item to other ItemEdit ItemReview ItemDelete ItemDelete DocumentExportImportReviewerSystemSuspect ChangesIntegrity

+

plantuml format="svg_inline" alt="Use Cases of Doorstop" title="Use Cases of Doorstop" +@startuml +Author --> (Create Document) +Author --> (Create Item) +Author --> (Link Item to Document) +Author --> (Link Item to other Item) +Author --> (Edit Item) +Author --> (Review Item) +Author -> (Delete Item) +Author -> (Delete Document) +(Export) <- (Author) +(Import) <- (Author) +Reviewer --> (Review Item) +System --> (Suspect Changes) +System --> (Integrity) +@enduml

2.1 REQ2-001

Hello, world!

Test Math Expressions in Latex Style:

diff --git a/doorstop/core/tests/test_all.py b/doorstop/core/tests/test_all.py index 155c325aa..243dc6cc0 100644 --- a/doorstop/core/tests/test_all.py +++ b/doorstop/core/tests/test_all.py @@ -11,6 +11,7 @@ import shutil import tempfile import unittest +from typing import List from unittest.mock import Mock, patch import openpyxl @@ -649,8 +650,17 @@ def test_lines_markdown_document_without_child_links(self): self.assertEqual(expected, text) common.write_text(text, path) - def test_lines_html_document_linkify(self): + @patch("plantuml_markdown.PlantUMLPreprocessor.run") + @patch("plantuml_markdown.PlantUMLPreprocessor.__init__") + def test_lines_html_document_linkify(self, ext_init, ext_run): """Verify HTML can be published from a document.""" + + def run(lines: List[str]) -> List[str]: + return lines + + ext_init.return_value = None + ext_run.side_effect = run + path = os.path.join(FILES, "published.html") expected = common.read_text(path) # Act @@ -664,9 +674,18 @@ def test_lines_html_document_linkify(self): common.write_text(actual, path) self.assertEqual(expected, actual) + @patch("plantuml_markdown.PlantUMLPreprocessor.run") + @patch("plantuml_markdown.PlantUMLPreprocessor.__init__") @patch("doorstop.settings.PUBLISH_CHILD_LINKS", False) - def test_lines_html_document_without_child_links(self): + def test_lines_html_document_without_child_links(self, ext_init, ext_run): """Verify HTML can be published from a document w/o child links.""" + + def run(lines: List[str]) -> List[str]: + return lines + + ext_init.return_value = None + ext_run.side_effect = run + path = os.path.join(FILES, "published2.html") expected = common.read_text(path) # Act