Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions md2cf/upsert.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ def page_needs_updating(page, existing_page, replace_all_labels):
# print(f"Page labels have changed: {page.title} {page.labels}")
return True
else:
existing_page_hash_match = CONTENT_HASH_REGEX.search(
existing_page.version.message
existing_page_hash_match = (
CONTENT_HASH_REGEX.search(existing_page.version.message)
if hasattr(existing_page.version, "message")
else None
)
if existing_page_hash_match is not None:
original_page_hash = existing_page_hash_match.group(1)
Expand Down
20 changes: 20 additions & 0 deletions test_package/unit/test_upsert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import pytest

import md2cf.upsert
from md2cf.api import Bunch
from md2cf.api import MinimalConfluence as Confluence
from md2cf.document import Page

Expand Down Expand Up @@ -224,6 +225,25 @@ def test_upsert_page_only_changed_no_changes(mocker):
assert upsert_result.action == upsert_result.action.SKIPPED


def test_page_needs_updating_when_no_message(mocker):
existing_page_mock = mocker.Mock()
ancestor_mock = mocker.Mock()
ancestor_mock.id = mocker.sentinel.parent_id
existing_page_mock.ancestors = [ancestor_mock]
existing_page_mock.version = Bunch()

page = Page(
space=mocker.sentinel.space,
title=mocker.sentinel.title,
body="hello there",
parent_id=mocker.sentinel.parent_id,
)

assert md2cf.upsert.page_needs_updating(
page, existing_page_mock, replace_all_labels=False
)


def test_page_needs_updating_page_not_changed(mocker):
message_hash = "[v6e71b3cac15d32fe2d36c270887df9479c25c640]"
existing_page_mock = mocker.Mock()
Expand Down