From 138578d782573fcccf6f6b38b4f5ce8255143d93 Mon Sep 17 00:00:00 2001 From: Tobias Brox Date: Sat, 7 Dec 2024 11:40:42 +0100 Subject: [PATCH] inaccurate datesearch --- check_server_compatibility.py | 25 +++++++++++++++++++------ tests/compatibility_issues.py | 3 +++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/check_server_compatibility.py b/check_server_compatibility.py index 7fe68bf..029e47f 100755 --- a/check_server_compatibility.py +++ b/check_server_compatibility.py @@ -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 @@ -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(), @@ -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 @@ -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 diff --git a/tests/compatibility_issues.py b/tests/compatibility_issues.py index ae19ff0..addcab5 100644 --- a/tests/compatibility_issues.py +++ b/tests/compatibility_issues.py @@ -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""",