mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-20 19:55:25 -04:00
Harden CalDAV write-back with retries (#1193)
Co-authored-by: Alexandre Teixeira <111787685+alteixeira20@users.noreply.github.com>
This commit is contained in:
@@ -22,7 +22,9 @@ CAL_ID = _stable_cal_id(REMOTE_URL)
|
||||
|
||||
|
||||
class FakeEvent:
|
||||
def __init__(self):
|
||||
def __init__(self, url="https://p69-caldav.icloud.com/123/calendars/home/evt-1.ics"):
|
||||
self.url = url
|
||||
self.etag = '"abc123"'
|
||||
self.data = "OLD"
|
||||
self.saved = False
|
||||
self.deleted = False
|
||||
@@ -39,6 +41,7 @@ class FakeCalendar:
|
||||
self.url = url
|
||||
self._existing = existing
|
||||
self.saved_ical = None
|
||||
self.created = FakeEvent(str(url).rstrip("/") + "/created.ics")
|
||||
|
||||
def event_by_uid(self, uid):
|
||||
if self._existing is None:
|
||||
@@ -47,6 +50,7 @@ class FakeCalendar:
|
||||
|
||||
def save_event(self, ical):
|
||||
self.saved_ical = ical
|
||||
return self.created
|
||||
|
||||
|
||||
def _ev(**over):
|
||||
@@ -91,6 +95,8 @@ def test_push_create_calls_save_event():
|
||||
res = push_event([cal], CAL_ID, _ev(), delete=False)
|
||||
assert res["ok"] and res.get("created")
|
||||
assert cal.saved_ical and "UID:evt-1" in cal.saved_ical
|
||||
assert res["calendar_url"] == REMOTE_URL
|
||||
assert res["remote_href"].endswith("/created.ics")
|
||||
|
||||
|
||||
def test_push_update_overwrites_existing():
|
||||
@@ -100,6 +106,8 @@ def test_push_update_overwrites_existing():
|
||||
assert res["ok"] and res.get("updated")
|
||||
assert existing.saved and "SUMMARY:Moved" in existing.data
|
||||
assert cal.saved_ical is None # used update path, not create
|
||||
assert res["remote_href"].endswith("evt-1.ics")
|
||||
assert res["remote_etag"] == '"abc123"'
|
||||
|
||||
|
||||
def test_push_delete_removes_existing():
|
||||
|
||||
Reference in New Issue
Block a user