mirror of
https://github.com/Kozea/Radicale.git
synced 2025-08-01 18:18:31 +00:00
Fix setting recurrence-id for expanded items. test for report with expand
finished
This commit is contained in:
parent
513415d201
commit
d1da63569b
2 changed files with 56 additions and 25 deletions
|
@ -207,30 +207,23 @@ def _expand(
|
||||||
|
|
||||||
expanded = None
|
expanded = None
|
||||||
for recurrence_dt in recurrences:
|
for recurrence_dt in recurrences:
|
||||||
expanded_item_ = copy.copy(expanded_item)
|
vobject_item = copy.copy(expanded_item.vobject_item)
|
||||||
|
|
||||||
try:
|
|
||||||
delattr(expanded_item_.vobject_item.vevent, 'recurrence-id')
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
recurrence_utc = recurrence_dt.astimezone(datetime.timezone.utc)
|
recurrence_utc = recurrence_dt.astimezone(datetime.timezone.utc)
|
||||||
|
|
||||||
vevent = copy.deepcopy(expanded_item_.vobject_item.vevent)
|
vevent = copy.deepcopy(vobject_item.vevent)
|
||||||
recurrence_id = ContentLine(
|
vevent.recurrence_id = ContentLine(
|
||||||
name='RECURRENCE-ID',
|
name='RECURRENCE-ID',
|
||||||
value=recurrence_utc.strftime('%Y%m%dT%H%M%SZ'), params={}
|
value=recurrence_utc.strftime('%Y%m%dT%H%M%SZ'), params={}
|
||||||
)
|
)
|
||||||
vevent.add(recurrence_id)
|
|
||||||
|
|
||||||
if expanded is None:
|
if expanded is None:
|
||||||
expanded_item_.vobject_item.vevent.add(recurrence_id)
|
vobject_item.vevent = vevent
|
||||||
expanded_item_.vobject_item.remove(expanded_item_.vobject_item.vevent)
|
expanded = vobject_item
|
||||||
expanded = expanded_item_
|
|
||||||
else:
|
else:
|
||||||
expanded.vobject_item.add(vevent)
|
expanded.add(vevent)
|
||||||
|
|
||||||
element.text = expanded.vobject_item.serialize()
|
element.text = expanded.serialize()
|
||||||
else:
|
else:
|
||||||
element.text = expanded_item.vobject_item.serialize()
|
element.text = expanded_item.vobject_item.serialize()
|
||||||
|
|
||||||
|
|
|
@ -1527,8 +1527,44 @@ permissions: RrWw""")
|
||||||
|
|
||||||
def test_report_with_expand_property(self) -> None:
|
def test_report_with_expand_property(self) -> None:
|
||||||
self.put("/calendar.ics/", get_file_content("event_daily_rrule.ics"))
|
self.put("/calendar.ics/", get_file_content("event_daily_rrule.ics"))
|
||||||
|
req_body_without_expand = \
|
||||||
|
"""<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
|
<D:prop>
|
||||||
|
<C:calendar-data>
|
||||||
|
</C:calendar-data>
|
||||||
|
</D:prop>
|
||||||
|
<C:filter>
|
||||||
|
<C:comp-filter name="VCALENDAR">
|
||||||
|
<C:comp-filter name="VEVENT">
|
||||||
|
<C:time-range start="20060103T000000Z" end="20060105T000000Z"/>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:comp-filter>
|
||||||
|
</C:filter>
|
||||||
|
</C:calendar-query>
|
||||||
|
"""
|
||||||
|
_, responses = self.report("/calendar.ics/", req_body_without_expand)
|
||||||
|
assert len(responses) == 1
|
||||||
|
|
||||||
req_body = \
|
response = responses['/calendar.ics/event_daily_rrule.ics']
|
||||||
|
status, element = list(response.values())[0]
|
||||||
|
|
||||||
|
assert status == 200
|
||||||
|
|
||||||
|
assert "RRULE" in element.text
|
||||||
|
assert "BEGIN:VTIMEZONE" in element.text
|
||||||
|
assert "RECURRENCE-ID" not in element.text
|
||||||
|
|
||||||
|
uids = []
|
||||||
|
for line in element.text.split("\n"):
|
||||||
|
if line.startswith("UID:"):
|
||||||
|
uid = line[len("UID:"):]
|
||||||
|
assert uid == "event_daily_rrule"
|
||||||
|
uids.append(uids)
|
||||||
|
|
||||||
|
assert len(uids) == 1
|
||||||
|
|
||||||
|
req_body_with_expand = \
|
||||||
"""<?xml version="1.0" encoding="utf-8" ?>
|
"""<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
|
<C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
|
||||||
<D:prop>
|
<D:prop>
|
||||||
|
@ -1546,27 +1582,29 @@ permissions: RrWw""")
|
||||||
</C:calendar-query>
|
</C:calendar-query>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# status, _, answer = self.request("REPORT", "/calendar.ics/", req_body, check=207)
|
_, responses = self.report("/calendar.ics/", req_body_with_expand)
|
||||||
# print(status, answer)
|
|
||||||
|
|
||||||
_, responses = self.report("/calendar.ics/", req_body)
|
|
||||||
assert len(responses) == 1
|
assert len(responses) == 1
|
||||||
|
|
||||||
response = responses['/calendar.ics/event_daily_rrule.ics']
|
response = responses['/calendar.ics/event_daily_rrule.ics']
|
||||||
status, element = list(response.values())[0]
|
status, element = list(response.values())[0]
|
||||||
assert status == 200
|
|
||||||
|
|
||||||
print("resp", status, element, flush=True)
|
assert status == 200
|
||||||
|
assert "RRULE" not in element.text
|
||||||
|
assert "BEGIN:VTIMEZONE" not in element.text
|
||||||
|
|
||||||
uids = []
|
uids = []
|
||||||
|
recurrence_ids = []
|
||||||
for line in element.text.split("\n"):
|
for line in element.text.split("\n"):
|
||||||
print("line", line, line.startswith("UID:"))
|
|
||||||
if line.startswith("UID:"):
|
if line.startswith("UID:"):
|
||||||
uid = line[len("UID:"):]
|
assert line == "UID:event_daily_rrule"
|
||||||
assert uid == "event_daily_rrule"
|
|
||||||
uids.append(uids)
|
uids.append(uids)
|
||||||
|
|
||||||
assert len(uids) == 3
|
if line.startswith("RECURRENCE-ID:"):
|
||||||
assert False
|
recurrence_ids.append(line)
|
||||||
|
|
||||||
|
assert len(uids) == 2
|
||||||
|
assert len(set(recurrence_ids)) == 2
|
||||||
|
|
||||||
def test_propfind_sync_token(self) -> None:
|
def test_propfind_sync_token(self) -> None:
|
||||||
"""Retrieve the sync-token with a propfind request"""
|
"""Retrieve the sync-token with a propfind request"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue