Skip to content

Commit 46f23f5

Browse files
committed
feat: check object mutability
Long, long time ago I ran the tests towards the legacy Google API and observed that PUT against an event did not work. This commit adds a test for this, though as I haven't tested it towards any server with this problem it's not really tested. This commit was AI-generated, prompt has been lost, but I believe it was done en-passant while cleaning up the compatibility_hints.py in the CalDAV library.
1 parent af66cba commit 46f23f5

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

src/caldav_server_tester/checks.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,57 @@ def add_if_not_existing(*largs, **kwargs):
757757
self._check_get_by_url(calendar)
758758

759759

760+
class CheckMutable(Check):
761+
"""
762+
Checks whether the server allows modification of existing calendar objects.
763+
764+
Modifies the SUMMARY of csc_simple_event1, saves it, reloads it, and
765+
verifies the server accepted the update. Replaces the old 'no_overwrite'
766+
compatibility flag.
767+
"""
768+
769+
depends_on = {PrepareCalendar}
770+
features_to_be_checked = {"save-load.mutable"}
771+
772+
def _run_check(self) -> None:
773+
cal = self.checker.calendar
774+
uid = "csc_simple_event1"
775+
776+
try:
777+
event = cal.event_by_uid(uid)
778+
except NotFoundError:
779+
event = Event(cal.client, url=cal.url.join(uid + ".ics"), parent=cal)
780+
781+
vevent = event.icalendar_instance.walk("VEVENT")[0]
782+
original_summary = str(vevent.get("SUMMARY", ""))
783+
modified_summary = original_summary + " (mutable-check)"
784+
785+
try:
786+
vevent["SUMMARY"] = modified_summary
787+
event.save()
788+
event.load()
789+
790+
vevent_reloaded = event.icalendar_instance.walk("VEVENT")[0]
791+
current_summary = str(vevent_reloaded.get("SUMMARY", ""))
792+
793+
if current_summary == modified_summary:
794+
self.set_feature("save-load.mutable")
795+
else:
796+
self.set_feature(
797+
"save-load.mutable",
798+
{"support": "broken", "behaviour": "modification not reflected after save and reload"},
799+
)
800+
except (DAVError, AuthorizationError):
801+
self.set_feature("save-load.mutable", False)
802+
finally:
803+
try:
804+
vevent_restore = event.icalendar_instance.walk("VEVENT")[0]
805+
vevent_restore["SUMMARY"] = original_summary
806+
event.save()
807+
except Exception:
808+
pass
809+
810+
760811
class CheckSearch(Check):
761812
depends_on = {PrepareCalendar}
762813
features_to_be_checked = {

0 commit comments

Comments
 (0)