Skip to content

Commit

Permalink
Make tests ignore broken server-side expand for radicale - updates #439
Browse files Browse the repository at this point in the history
  • Loading branch information
tobixen committed Oct 20, 2024
1 parent 0fdf00d commit 6f0bd41
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 24 deletions.
14 changes: 9 additions & 5 deletions caldav/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -1228,21 +1228,25 @@ def search(
objects = [o for o in objects if o.has_component()]

if kwargs.get("expand", False):
## expand can only be used together with start and end.
## Error checking is done in build_search_xml_query. If
## search is fed with an XML query together with expand,
## then it's considered a "search option", and an error is
## raised above.
## expand can only be used together with start and end (and not
## with xml). Error checking has already been done in
## build_search_xml_query above.
start = kwargs["start"]
end = kwargs["end"]

## Verify that any recurring objects returned are already expanded
for o in objects:
component = o.icalendar_component
if component is None:
continue
recurrence_properties = ["exdate", "exrule", "rdate", "rrule"]
if any(key in component for key in recurrence_properties):
o.expand_rrule(start, end)

## An expanded recurring object comes as one Event() with
## icalendar data containing multiple objects. The caller may
## expect multiple Event()s. This code splits events into
## separate objects:
if split_expanded:
objects_ = objects
objects = []
Expand Down
14 changes: 5 additions & 9 deletions tests/compatibility_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,14 @@
## * Perhaps some more readable format should be considered (yaml?).
## * Consider how to get this into the documentation
incompatibility_description = {
'no_expand':
"""Server may throw errors when asked to do an expanded date search (this is ignored by the tests now, as we're doing client-side expansion)""",
'broken_expand':
"""Server-side expand seems to work, but delivers wrong data""",

'no_recurring':
"""Server is having issues with recurring events and/or todos. """
"""date searches covering recurrances may yield no results, """
"""and events/todos may not be expanded with recurrances""",

'no_recurring_expandation':
"""Server will not expand recurring events (this is ignored by the tests now, as we're doing client-side expansion)""",

'no_recurring_todo':
"""Recurring events are supported, but not recurring todos""",

Expand Down Expand Up @@ -203,7 +200,7 @@

xandikos = [
## https://github.com/jelmer/xandikos/issues/8
"no_expand", "no_recurring",
"no_recurring",

'text_search_is_exact_match_only',

Expand All @@ -217,6 +214,7 @@
radicale = [
## calendar listings and calendar creation works a bit
## "weird" on radicale
"broken_expand",
"no_default_calendar",
"non_existing_calendar_found",

Expand All @@ -227,6 +225,7 @@
"radicale_breaks_on_category_search",

'no_scheduling',
'no_todo_datesearch',

'text_search_is_case_insensitive',
'text_search_is_exact_match_sometimes',
Expand Down Expand Up @@ -290,7 +289,6 @@
## (TODO: do some research on this)
'sync_breaks_on_delete',
'no_recurring_todo',
'no_recurring_todo_expand',
'non_existing_calendar_found',
'combined_search_not_working',
'text_search_is_exact_match_sometimes',
Expand Down Expand Up @@ -324,7 +322,6 @@
'no_mkcalendar',
'no_overwrite',
'no_todo',
'no_recurring_expandation'
]

## https://www.sogo.nu/bugs/view.php?id=3065
Expand All @@ -345,7 +342,6 @@
nextcloud = [
'sync_breaks_on_delete',
'no_recurring_todo',
'no_recurring_todo_expand',
'combined_search_not_working',
'text_search_is_exact_match_sometimes',
]
Expand Down
18 changes: 8 additions & 10 deletions tests/test_caldav.py
Original file line number Diff line number Diff line change
Expand Up @@ -1848,18 +1848,17 @@ def testTodoDatesearch(self):
# t5 has dtstart and due set prior to the search window
# t6 has dtstart and due set prior to the search window, but is yearly recurring.
# What will a date search yield?
noexpand = self.check_compatibility_flag("no_expand")
todos1 = c.date_search(
start=datetime(1997, 4, 14),
end=datetime(2015, 5, 14),
compfilter="VTODO",
expand=not noexpand,
expand=True,
)
todos2 = c.search(
start=datetime(1997, 4, 14),
end=datetime(2015, 5, 14),
todo=True,
expand=not noexpand,
expand=True,
split_expanded=False,
include_completed=True,
)
Expand Down Expand Up @@ -1893,11 +1892,9 @@ def testTodoDatesearch(self):
assert len(todos2) == foo

## verify that "expand" works
if (
not self.check_compatibility_flag("no_expand")
and not self.check_compatibility_flag("no_recurring")
and not self.check_compatibility_flag("no_recurring_todo")
):
if not self.check_compatibility_flag(
"broken_expand"
) and not self.check_compatibility_flag("no_recurring"):
assert len([x for x in todos1 if "DTSTART:20020415T1330" in x.data]) == 1
assert len([x for x in todos2 if "DTSTART:20020415T1330" in x.data]) == 1

Expand Down Expand Up @@ -2444,8 +2441,9 @@ def testRecurringDateSearch(self):
assert r1[0].data.count("END:VEVENT") == 1
assert r2[0].data.count("END:VEVENT") == 1
## due to expandation, the DTSTART should be in 2008
assert r1[0].data.count("DTSTART;VALUE=DATE:2008") == 1
assert r2[0].data.count("DTSTART;VALUE=DATE:2008") == 1
if not self.check_compatibility_flag("broken_expand"):
assert r1[0].data.count("DTSTART;VALUE=DATE:2008") == 1
assert r2[0].data.count("DTSTART;VALUE=DATE:2008") == 1

## With expand=True and searching over two recurrences ...
r1 = c.date_search(
Expand Down

0 comments on commit 6f0bd41

Please sign in to comment.