Skip to content

Commit

Permalink
inaccurate datesearch
Browse files Browse the repository at this point in the history
  • Loading branch information
tobixen committed Dec 7, 2024
1 parent ac5f246 commit 138578d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
25 changes: 19 additions & 6 deletions check_server_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def _fix_cal(self, todo=False):
if self.flags_checked['no_mkcalendar']:
cal = self.principal.calendars()[0]
if cal.events() or cal.todos():
import pdb; pdb.set_trace()
raise "Refusing to run tests on a calendar with content"
self._default_calendar = cal
return cal
Expand Down Expand Up @@ -372,8 +373,6 @@ def _check_prop(self, propclass, silly_value, test_value):
def check_event(self):
cal = self._default_calendar

import pdb; pdb.set_trace()

## Two simple events with text fields, dtstart=now and no dtend
obj1 = cal.add_event(
dtstart=datetime.now(),
Expand Down Expand Up @@ -653,12 +652,15 @@ def _do_date_search(self, assert_found=True, has_duration=True, **kwargs):
7: search with start during event
"""
cal = self._default_calendar
longbefore = datetime(2000, 6, 30, 4)
longbefore = datetime(2000, 5, 30, 4)
before = datetime(2000, 7, 1, 4)
during1 = datetime(2000, 7, 1, 10)
during2 = datetime(2000, 7, 1, 12)
after = datetime(2000, 7, 1, 22)
longafter = datetime(2000, 7, 2, 10)
longafter = datetime(2000, 9, 2, 10)
if self.flags_checked.get('inaccurate_datesearch'):
before = before - timedelta(days=31)
after = after + timedelta(days=31)
one_event_lists = [
## open-ended searches, should yield object
cal.search(end=after, **kwargs), ## 0
Expand Down Expand Up @@ -702,9 +704,20 @@ def _do_date_search(self, assert_found=True, has_duration=True, **kwargs):
self.set_flag("vtodo_datesearch_nostart_future_tasks_delivered", True)
assert len(cal.search(end=before, **kwargs)) == 1
else:
import pdb; pdb.set_trace()
assert len(cal.search(end=before, **kwargs)) == 0
none = cal.search(end=before, **kwargs)
if none:
none = cal.search(end=longbefore, **kwargs)
assert not none
self.set_flag("inaccurate_datesearch")
before = before - timedelta(days=31)
after = after + timedelta(days=31)
else:
if not 'inaccurate_Datesearch' in self.flags_checked:
self.set_flag("inaccurate_datesearch", False)

assert len(cal.search(start=after, end=longafter)) == 0
if len(cal.search(start=after, **kwargs)):
import pdb; pdb.set_trace()
assert len(cal.search(start=after, **kwargs)) == 0
return ret

Expand Down
3 changes: 3 additions & 0 deletions tests/compatibility_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@
"""it asserts DAV:allprop response contains the text 'resourcetype', """
"""possibly this assert is wrong""",

'inaccurate_datesearch':
"""Searching by datetime seems to have a one-day resolution, so if searching for events over a timespan of hours, all events for the day is found""",

'no_todo':
"""Support for VTODO (tasks) apparently missing""",

Expand Down

0 comments on commit 138578d

Please sign in to comment.