Skip to content

Commit ffaa7e4

Browse files
committed
alarm creation and search works
1 parent d29e7d9 commit ffaa7e4

3 files changed

Lines changed: 24 additions & 6 deletions

File tree

caldav/davclient.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,9 @@ def _expand_simple_prop(
310310
values = []
311311
if proptag in props_found:
312312
prop_xml = props_found[proptag]
313-
error.assert_(not prop_xml.items())
313+
if prop_xml.items():
314+
from caldav.lib.debug import xmlstring
315+
log.error(f"If you see this, please add a report at https://github.com/python-caldav/caldav/issues/209 - in _expand_simple_prop, dealing with {proptag}, extra items found: {xmlstring(prop_xml)}.")
314316
if not xpath and len(prop_xml) == 0:
315317
if prop_xml.text:
316318
values.append(prop_xml.text)

tests/compatibility_issues.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
"""date searches covering recurrances may yield no results, """
4545
"""and events/todos may not be expanded with recurrances""",
4646

47+
'no_alarmsearch':
48+
"""Searching for alarms may yield too few or too many or even a 500 internal server error""",
49+
4750
'no_recurring_todo':
4851
"""Recurring events are supported, but not recurring todos""",
4952

@@ -271,6 +274,9 @@
271274
## rather than date, just to have the test exercised ... but we
272275
## should report this upstream
273276
#'broken_expand_on_exceptions',
277+
278+
## No alarm search (500 internal server error)
279+
"no_alarmsearch",
274280
]
275281

276282
## This can soon be removed (relevant for running tests under python 3.7 and python 3.8)
@@ -286,11 +292,14 @@
286292
except Exception:
287293
pass
288294

295+
## TODO - there has been quite some development in radicale recently, so this list
296+
## should probably be gone through
289297
radicale = [
290298
## calendar listings and calendar creation works a bit
291299
## "weird" on radicale
292300
"broken_expand",
293301
"no_default_calendar",
302+
"no_alarmsearch", ## This is fixed and will be released soon
294303

295304
## freebusy is not supported yet, but on the long-term road map
296305
#"no_freebusy_rfc4791",

tests/test_caldav.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -987,14 +987,19 @@ def testAlarm(self):
987987
## Ref https://github.com/python-caldav/caldav/issues/132
988988
c = self._fixCalendar()
989989
ev = c.save_event(
990-
dtstart=datetime(2015, 10, 10, 8, 7, 6),
990+
dtstart=datetime(2015, 10, 10, 8, 0, 0),
991991
summary="This is a test event",
992-
dtend=datetime(2016, 10, 10, 9, 8, 7),
992+
dtend=datetime(2016, 10, 10, 9, 0, 0),
993993
alarm_trigger=timedelta(minutes=-15),
994994
alarm_action="AUDIO",
995995
)
996996

997-
## Search for the alarm (procrastinated - see https://github.com/python-caldav/caldav/issues/132)
997+
self.skip_on_compatibility_flag("no_alarmsearch")
998+
999+
## So we have an alarm that goes off 07:45 for an event starting 08:00
1000+
1001+
## Search for alarms after 8 should find nothing
1002+
## (search for an alarm 07:55 - 08:05 should most likely find nothing).
9981003
assert (
9991004
len(
10001005
c.search(
@@ -1005,12 +1010,14 @@ def testAlarm(self):
10051010
)
10061011
== 0
10071012
)
1013+
1014+
## Search for alarms from 07:40 to 07:55 should definitively find the alarm.
10081015
assert (
10091016
len(
10101017
c.search(
10111018
event=True,
1012-
alarm_start=datetime(2015, 10, 10, 7, 44),
1013-
alarm_end=datetime(2015, 10, 10, 8, 7),
1019+
alarm_start=datetime(2015, 10, 10, 7, 40),
1020+
alarm_end=datetime(2015, 10, 10, 7, 55),
10141021
)
10151022
)
10161023
== 1

0 commit comments

Comments
 (0)