diff --git a/check_server_compatibility.py b/check_server_compatibility.py index 00d6e9f..b371c99 100755 --- a/check_server_compatibility.py +++ b/check_server_compatibility.py @@ -72,17 +72,19 @@ def _try_make_calendar(self, cal_id, **kwargs): self.set_flag("no_mkcalendar", False) self.set_flag("read_only", False) self.principal.calendar(cal_id=cal_id).events() - import pdb; pdb.set_trace() - if kwargs.get('name'): + import pdb + + pdb.set_trace() + if kwargs.get("name"): try: - name = 'A calendar with this name should not exist' + name = "A calendar with this name should not exist" self.principal.calendar(name=name).events() except: ## This is not the exception, this is the normal try: - cal2 = self.principal.calendar(name=kwargs['name']) + cal2 = self.principal.calendar(name=kwargs["name"]) cal2.events() - assert(cal2.id == cal.id) + assert cal2.id == cal.id self.set_flag("no_displayname", False) except: self.set_flag("no_displayname", True) @@ -185,7 +187,9 @@ def check_mkcalendar(self): except: self.set_flag("no_default_calendar", True) - import pdb; pdb.set_trace() + import pdb + + pdb.set_trace() makeret = self._try_make_calendar(name="Yep", cal_id="pythoncaldav-test") if makeret[0]: ## calendar created @@ -208,7 +212,7 @@ def check_mkcalendar(self): self.set_flag("no_mkcalendar", True) def _fix_cal_if_needed(self, todo=False): - if self.flags_checked['no_delete_event']: + if self.flags_checked["no_delete_event"]: return self._fix_cal(todo=todo) else: return self._default_calendar @@ -218,15 +222,15 @@ def _fix_cal(self, todo=False): if self._default_calendar: self._default_calendar.delete() if todo: - kwargs['supported_calendar_component_set'] = ["VTODO"] - if self.flags_checked['unique_calendar_ids']: - kwargs['cal_id'] = "testcalendar-" + str(uuid.uuid4()) + kwargs["supported_calendar_component_set"] = ["VTODO"] + if self.flags_checked["unique_calendar_ids"]: + kwargs["cal_id"] = "testcalendar-" + str(uuid.uuid4()) else: - kwargs['cal_id'] = "pythoncaldav-test" - if self.flags_checked['no_displayname']: - kwargs['name'] = None + kwargs["cal_id"] = "pythoncaldav-test" + if self.flags_checked["no_displayname"]: + kwargs["name"] = None else: - kwargs['name'] = "CalDAV Server Testing" + kwargs["name"] = "CalDAV Server Testing" cal = self.principal.make_calendar(**kwargs) self._default_calendar = cal return cal @@ -318,13 +322,13 @@ def check_event(self): finally: yearly_time.delete() yearly_day.delete() - + if cal.events(): ## Zimbra. Probably related to event_by_url_is_broken - self.set_flag('no_delete_event') + self.set_flag("no_delete_event") cal = self._fix_cal() else: - self.set_flag('no_delete_event', False) + self.set_flag("no_delete_event", False) ## Finally, a check that searches involving timespans works as intended span = cal.add_event( @@ -336,7 +340,9 @@ def check_event(self): foo = self._date_search(span, assert_found=False, event=True) if len(foo) != 0: - import pdb; pdb.set_trace() + import pdb + + pdb.set_trace() raise span = cal.add_event( @@ -347,10 +353,10 @@ def check_event(self): ) ret = self._date_search(span, assert_found=False, event=True) if ret == [4, 6, 7]: - self.set_flag('date_search_ignores_duration') + self.set_flag("date_search_ignores_duration") else: - self.set_flag('date_search_ignores_duration', False) - assert len(ret)==0 + self.set_flag("date_search_ignores_duration", False) + assert len(ret) == 0 def _check_simple_events(self, obj1, obj2): cal = self._default_calendar @@ -511,53 +517,63 @@ def _do_date_search(self, assert_found=True, has_duration=True, **kwargs): 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, 7, 2, 10) one_event_lists = [ ## open-ended searches, should yield object cal.search(end=after, **kwargs), cal.search(start=before, **kwargs), - cal.search(start=before, end=after, **kwargs) + cal.search(start=before, end=after, **kwargs), ] if has_duration: ## overlapping searches, everything should yield object - one_event_lists.extend([ - cal.search(end=during1, **kwargs), - cal.search(start=during1, **kwargs), - cal.search(start=before, end=during1, **kwargs), - cal.search(start=during1, end=during2, **kwargs), - cal.search(start=during1, end=after, **kwargs) - ]) + one_event_lists.extend( + [ + cal.search(end=during1, **kwargs), + cal.search(start=during1, **kwargs), + cal.search(start=before, end=during1, **kwargs), + cal.search(start=during1, end=during2, **kwargs), + cal.search(start=during1, end=after, **kwargs), + ] + ) ret = [] for i in range(0, len(one_event_lists)): - if not assert_found and len(one_event_lists[i])==0: + if not assert_found and len(one_event_lists[i]) == 0: ret.append(i) else: - assert len(one_event_lists[i])==1 - assert(len(cal.search(start=longbefore, end=before))==0) - if kwargs.get('todo'): - if len(cal.search(end=before, **kwargs))==0: - if not 'vtodo_datesearch_nostart_future_tasks_delivered' in self.flags_checked: - self.set_flag('vtodo_datesearch_nostart_future_tasks_delivered', False) + assert len(one_event_lists[i]) == 1 + assert len(cal.search(start=longbefore, end=before)) == 0 + if kwargs.get("todo"): + if len(cal.search(end=before, **kwargs)) == 0: + if ( + not "vtodo_datesearch_nostart_future_tasks_delivered" + in self.flags_checked + ): + self.set_flag( + "vtodo_datesearch_nostart_future_tasks_delivered", False + ) else: - self.set_flag('vtodo_datesearch_nostart_future_tasks_delivered', True) - assert len(cal.search(end=before, **kwargs))==1 + self.set_flag("vtodo_datesearch_nostart_future_tasks_delivered", True) + assert len(cal.search(end=before, **kwargs)) == 1 else: - assert len(cal.search(end=before, **kwargs))==0 - assert(len(cal.search(start=after, end=longafter))==0) - assert(len(cal.search(start=after, **kwargs))==0) + assert len(cal.search(end=before, **kwargs)) == 0 + assert len(cal.search(start=after, end=longafter)) == 0 + assert len(cal.search(start=after, **kwargs)) == 0 return ret def check_todo(self): cal = self._default_calendar simple = { - 'summary': "This is a summary", - 'uid': "check_todo_1", + "summary": "This is a summary", + "uid": "check_todo_1", } try: ## Add a simplest possible todo todo_simple = cal.add_todo(**simple) if not self.flags_checked["object_by_uid_is_broken"]: - assert str(cal.todo_by_uid("check_todo_1").icalendar_component['UID']) == 'check_todo_1' + assert ( + str(cal.todo_by_uid("check_todo_1").icalendar_component["UID"]) + == "check_todo_1" + ) self.set_flag("no_todo", False) except Exception as e: cal = self._fix_cal(todo=True) @@ -565,7 +581,10 @@ def check_todo(self): ## Add a simplest possible todo todo_simple = cal.add_todo(**simple) if not self.flags_checked["object_by_uid_is_broken"]: - assert str(cal.todo_by_uid("check_todo_1").icalendar_component['UID']) == 'check_todo_1' + assert ( + str(cal.todo_by_uid("check_todo_1").icalendar_component["UID"]) + == "check_todo_1" + ) self.set_flag("no_todo", False) self.set_flag("no_todo_on_standard_calendar") except: @@ -587,14 +606,18 @@ def check_todo(self): dtstart=datetime(2000, 7, 1, 8), uid="check_todo_2", ) - foobar1 = self._date_search(todo, assert_found=False, has_duration=False, todo=True) + foobar1 = self._date_search( + todo, assert_found=False, has_duration=False, todo=True + ) todo = cal.add_todo( summary="This has due", due=datetime(2000, 7, 1, 16), uid="check_todo_3", ) - foobar2 = self._date_search(todo, assert_found=False, has_duration=False, todo=True) + foobar2 = self._date_search( + todo, assert_found=False, has_duration=False, todo=True + ) todo = cal.add_todo( summary="This has dtstart and due", @@ -602,9 +625,9 @@ def check_todo(self): due=datetime(2000, 7, 1, 16), uid="check_todo_4", ) - + foobar3 = self._date_search(todo, assert_found=False, todo=True) - + todo = cal.add_todo( summary="This has dtstart and dur", dtstart=datetime(2000, 7, 1, 8), @@ -615,14 +638,14 @@ def check_todo(self): if len(foobar1 + foobar2 + foobar3 + foobar4) == 22: ## no todos found - self.set_flag('no_todo_datesearch') + self.set_flag("no_todo_datesearch") else: - self.set_flag('no_todo_datesearch', False) + self.set_flag("no_todo_datesearch", False) assert len(foobar1 + foobar2 + foobar3) == 0 if foobar4 == [4, 6, 7]: - self.set_flag('date_todo_search_ignores_duration') + self.set_flag("date_todo_search_ignores_duration") else: - assert len(foobar4)==0 + assert len(foobar4) == 0 def _check_simple_todo(self, todo): cal = self._default_calendar @@ -637,50 +660,57 @@ def _check_simple_todo(self, todo): ## I haven't seen that before. ## TODO: add a flag for this raise - + ## RFC says that a todo without dtstart/due is ## supposed to span over "infinite time". So itshould always appear ## in date searches. try: - todos = cal.search(start=datetime(2020,1,1), end=datetime(2020,1,2), todo=True) - assert len(todos) in (0,1) + todos = cal.search( + start=datetime(2020, 1, 1), end=datetime(2020, 1, 2), todo=True + ) + assert len(todos) in (0, 1) self.set_flag("vtodo_datesearch_notime_task_is_skipped", len(todos) == 0) except Exception as e: self.set_flag("no_todo_datesearch", True) - def _check_todo_date_search(self, todo_with_dtstart, todo_with_due, todo_with_dtstart_due, todo_with_dtstart_dur): + def _check_todo_date_search( + self, + todo_with_dtstart, + todo_with_due, + todo_with_dtstart_due, + todo_with_dtstart_dur, + ): if self.flag_checked["no_todo_datesearch"]: return ## Every check below should return one and only one task if ## everything works according to my understanding of the RFC one_task_lists = [] for start_end in [ - ## 0 - todo_with_dtstart - ((1999, 12, 31, 22, 22, 22),(2000, 1, 1, 0, 30)), - - ## 1 - todo_with_due - ((2000, 1, 1, 0, 30),(2000, 1, 1, 1, 30)), - - ## 2, 3, 4 - todo_with_dtstart_due - ((2000, 1, 1, 1, 30),(2000, 1, 1, 3, 30)), - ((2000, 1, 1, 1, 30),(2000, 1, 1, 2, 30)), - ((2000, 1, 1, 2, 30),(2000, 1, 1, 3, 30)), - - ## 5, 6, 7 - todo_with_dtstart_dur - ((2000, 1, 1, 3, 30),(2000, 1, 1, 5, 30)), - ((2000, 1, 1, 3, 30),(2000, 1, 1, 4, 30)), - ((2000, 1, 1, 4, 30),(2000, 1, 1, 5, 30)), + ## 0 - todo_with_dtstart + ((1999, 12, 31, 22, 22, 22), (2000, 1, 1, 0, 30)), + ## 1 - todo_with_due + ((2000, 1, 1, 0, 30), (2000, 1, 1, 1, 30)), + ## 2, 3, 4 - todo_with_dtstart_due + ((2000, 1, 1, 1, 30), (2000, 1, 1, 3, 30)), + ((2000, 1, 1, 1, 30), (2000, 1, 1, 2, 30)), + ((2000, 1, 1, 2, 30), (2000, 1, 1, 3, 30)), + ## 5, 6, 7 - todo_with_dtstart_dur + ((2000, 1, 1, 3, 30), (2000, 1, 1, 5, 30)), + ((2000, 1, 1, 3, 30), (2000, 1, 1, 4, 30)), + ((2000, 1, 1, 4, 30), (2000, 1, 1, 5, 30)), ]: - one_task_lists.append(cal.search(start=datetime(*start_end[0]), end=datetime(*start_end[1]))) + one_task_lists.append( + cal.search(start=datetime(*start_end[0]), end=datetime(*start_end[1])) + ) if sum([len(x) for x in one_task_lists]) == 0: - self.set_flag('no_todo_datesearch') + self.set_flag("no_todo_datesearch") return else: - self.set_flag('no_todo_datesearch', False) + self.set_flag("no_todo_datesearch", False) - for idx in range(0,8): - if not len(one_task_lists[idx])==1: + for idx in range(0, 8): + if not len(one_task_lists[idx]) == 1: debugging pass diff --git a/tests/compatibility_issues.py b/tests/compatibility_issues.py index f3d7535..8587258 100644 --- a/tests/compatibility_issues.py +++ b/tests/compatibility_issues.py @@ -192,7 +192,7 @@ 'date_search_ignores_duration': """Date search with search interval overlapping event interval works on events with dtstart and dtend, but not on events with dtstart and due""", - + 'date_todo_search_ignores_duration': """Same as above, but specifically for tasks""", diff --git a/tests/test_caldav.py b/tests/test_caldav.py index 43e6541..39f129b 100644 --- a/tests/test_caldav.py +++ b/tests/test_caldav.py @@ -560,7 +560,8 @@ def foo(*a, **kwa): return f(*a, **kwa) return foo - + + class RepeatedFunctionalTestsBaseClass: """This is a class with functional tests (tests that goes through basic functionality and actively communicates with third parties)