Skip to content

Commit e6acace

Browse files
committed
test(core): guard the skipped and verified page interaction
- a page kept by 'keep existing' must not enter the write verification - it stays in pages and skipped when a neighbour is reported missing - fails if edited_titles is filled outside the kept_existing guard
1 parent af682e1 commit e6acace

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

‎tests/test_overwrite_policy.py‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,3 +763,49 @@ def test_an_overwritten_existing_page_is_not_reported_as_skipped(monkeypatch):
763763
)
764764

765765
assert result.skipped == {}
766+
767+
768+
def test_a_skipped_page_is_not_verified_and_survives_a_failed_neighbour(monkeypatch):
769+
"""A kept page was never edited, so the write verification must ignore it.
770+
771+
'keep existing' and the write verification of #175 were written separately
772+
and first meet here. A kept page must not be queried, and must stay in
773+
'pages' and 'skipped' when the verification reports the other page of the
774+
same call as missing.
775+
"""
776+
existing = model.Item(label=[model.Label(text="Keep me")])
777+
created = model.Item(label=[model.Label(text="Create me")])
778+
kept_title = f"Item:{OSW.get_osw_id(existing.uuid)}"
779+
created_title = f"Item:{OSW.get_osw_id(created.uuid)}"
780+
verified = []
781+
782+
monkeypatch.setattr(
783+
WtPage, "init", lambda self: setattr(self, "exists", self.title == kept_title)
784+
)
785+
monkeypatch.setattr(
786+
WtPage, "get_url", lambda self: f"https://example.org/{self.title}"
787+
)
788+
monkeypatch.setattr(WtPage, "edit", lambda self, *a, **k: None)
789+
790+
def _missing(self, titles):
791+
verified.extend(titles)
792+
return [created_title]
793+
794+
monkeypatch.setattr(OSW, "_get_missing_page_titles", _missing)
795+
osw_obj = OSW.construct(site=object())
796+
797+
with pytest.raises(OSW.StoreEntityPartialError) as exc_info:
798+
osw_obj.store_entity(
799+
OSW.StoreEntityParam(
800+
entities=[existing, created],
801+
overwrite=AddOverwriteClassOptions.keep_existing,
802+
parallel=False,
803+
)
804+
)
805+
806+
err = exc_info.value
807+
assert verified == [created_title]
808+
assert kept_title in err.result.skipped
809+
assert kept_title in err.result.pages
810+
assert created_title in err.failed
811+
assert err.stored == []

0 commit comments

Comments
 (0)