Skip to content

Commit

Permalink
2nd test
Browse files Browse the repository at this point in the history
  • Loading branch information
szn committed Apr 6, 2024
1 parent 319c4f2 commit 19bccd6
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
15 changes: 11 additions & 4 deletions src/md2cf/utils/confluencemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,24 @@ 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")))
for issue in ISSUE_PATTERN_URL.finditer(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")
Expand Down
2 changes: 1 addition & 1 deletion src/tests/sample_2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 2 additions & 13 deletions src/tests/test_confluencemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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


0 comments on commit 19bccd6

Please sign in to comment.