From 19bccd6c253df9afce3a283616899dffd3f149b7 Mon Sep 17 00:00:00 2001 From: SZN Date: Sat, 6 Apr 2024 21:01:30 +0200 Subject: [PATCH] 2nd test --- src/md2cf/utils/confluencemd.py | 15 +++++++++++---- src/tests/sample_2.md | 2 +- src/tests/test_confluencemd.py | 15 ++------------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/src/md2cf/utils/confluencemd.py b/src/md2cf/utils/confluencemd.py index 6603438..ebf0fd6 100644 --- a/src/md2cf/utils/confluencemd.py +++ b/src/md2cf/utils/confluencemd.py @@ -240,9 +240,9 @@ def create_page(self, parent_id: str, title: str, overwrite: bool) -> None: self.__add_label_to_page(page_id) def __rewrite_issues(self, html): - if not self.convert_jira: - return - logger.debug("Replacing [ISSUE-KEY] with html links") + if self.convert_jira: + logger.debug("Replacing [ISSUE-KEY] with html links") + issues = [] for issue in ISSUE_PATTERN.finditer(html): issues.append((issue.group(), issue.group("key"))) @@ -250,7 +250,14 @@ def __rewrite_issues(self, html): if self.url.startswith(issue.group("domain")): issues.append((issue.group(), issue.group("key"))) else: - logger.info("Ignoring %s - domain mismatch (%s != %s)", issue.group(), issue.group("domain"), self.url) + if self.convert_jira: + logger.info("Ignoring %s - domain mismatch (%s != %s)", issue.group(), issue.group("domain"), self.url) + + if len(issues) and not self.convert_jira: + (replace, key) = issues[0] + logger.info("Use --convert_jira to replace %i Jira link(s) (such as %s) with issue snippets - KEY: summary [status]", + len(issues), key) + return html for (replace, key) in issues: logger.debug(f" - [{key}] with html link") diff --git a/src/tests/sample_2.md b/src/tests/sample_2.md index 810e7e5..2c70bca 100644 --- a/src/tests/sample_2.md +++ b/src/tests/sample_2.md @@ -5,4 +5,4 @@ confluence-url: https://dirtyagile.atlassian.net/wiki/spaces/AD/pages/1115848706 [KEY-1] -https://dirtyagil.atlassian.net/browse/AD-120 +https://dirtyagile.atlassian.net/browse/AD-120 diff --git a/src/tests/test_confluencemd.py b/src/tests/test_confluencemd.py index 8b66534..189e4fd 100644 --- a/src/tests/test_confluencemd.py +++ b/src/tests/test_confluencemd.py @@ -37,17 +37,6 @@ def test_create_page1(self, capsys, caplog, user, token): def test_create_page2(self, capsys, caplog, user, token): conf_md = TestConfluenceMD.init_confluencemd(user, token, "src/tests/sample_2.md") - with pytest.raises(AssertionError, match=r"Provide parent_id for a newly created page"): - conf_md.create_page("", "sample 1", None) - - with pytest.raises(AssertionError, match=r"Provide a title for a newly created page"): - conf_md.create_page("1115881473", "", None) - - with pytest.raises(AssertionError, match=r"Page titled `sample 1` already exists.*"): - conf_md.create_page("1115881473", "sample 1", False) - - with pytest.raises(ApiError, match=r"There is no content with the given id.*"): - conf_md.create_page("1", "sample 1", False) with pytest.raises(AssertionError, match=r"Metadata pointing to an existing page id.*"): conf_md.create_page("1115881473", "sample 2", False) @@ -56,7 +45,7 @@ def test_create_page2(self, capsys, caplog, user, token): assert captured.out == "" for record in caplog.records: - assert record.levelname == "DEBUG" - assert "found page_id `1115848706`" in caplog.text + assert record.levelname in ["INFO", "DEBUG"] + assert "Use --convert_jira to replace 2 Jira link" in caplog.text \ No newline at end of file