Skip to content

Commit 65bb875

Browse files
committed
style fixup
1 parent c112d27 commit 65bb875

3 files changed

Lines changed: 111 additions & 80 deletions

File tree

check_server_compatibility.py

Lines changed: 108 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,19 @@ def _try_make_calendar(self, cal_id, **kwargs):
7272
self.set_flag("no_mkcalendar", False)
7373
self.set_flag("read_only", False)
7474
self.principal.calendar(cal_id=cal_id).events()
75-
import pdb; pdb.set_trace()
76-
if kwargs.get('name'):
75+
import pdb
76+
77+
pdb.set_trace()
78+
if kwargs.get("name"):
7779
try:
78-
name = 'A calendar with this name should not exist'
80+
name = "A calendar with this name should not exist"
7981
self.principal.calendar(name=name).events()
8082
except:
8183
## This is not the exception, this is the normal
8284
try:
83-
cal2 = self.principal.calendar(name=kwargs['name'])
85+
cal2 = self.principal.calendar(name=kwargs["name"])
8486
cal2.events()
85-
assert(cal2.id == cal.id)
87+
assert cal2.id == cal.id
8688
self.set_flag("no_displayname", False)
8789
except:
8890
self.set_flag("no_displayname", True)
@@ -185,7 +187,9 @@ def check_mkcalendar(self):
185187
except:
186188
self.set_flag("no_default_calendar", True)
187189

188-
import pdb; pdb.set_trace()
190+
import pdb
191+
192+
pdb.set_trace()
189193
makeret = self._try_make_calendar(name="Yep", cal_id="pythoncaldav-test")
190194
if makeret[0]:
191195
## calendar created
@@ -208,7 +212,7 @@ def check_mkcalendar(self):
208212
self.set_flag("no_mkcalendar", True)
209213

210214
def _fix_cal_if_needed(self, todo=False):
211-
if self.flags_checked['no_delete_event']:
215+
if self.flags_checked["no_delete_event"]:
212216
return self._fix_cal(todo=todo)
213217
else:
214218
return self._default_calendar
@@ -218,15 +222,15 @@ def _fix_cal(self, todo=False):
218222
if self._default_calendar:
219223
self._default_calendar.delete()
220224
if todo:
221-
kwargs['supported_calendar_component_set'] = ["VTODO"]
222-
if self.flags_checked['unique_calendar_ids']:
223-
kwargs['cal_id'] = "testcalendar-" + str(uuid.uuid4())
225+
kwargs["supported_calendar_component_set"] = ["VTODO"]
226+
if self.flags_checked["unique_calendar_ids"]:
227+
kwargs["cal_id"] = "testcalendar-" + str(uuid.uuid4())
224228
else:
225-
kwargs['cal_id'] = "pythoncaldav-test"
226-
if self.flags_checked['no_displayname']:
227-
kwargs['name'] = None
229+
kwargs["cal_id"] = "pythoncaldav-test"
230+
if self.flags_checked["no_displayname"]:
231+
kwargs["name"] = None
228232
else:
229-
kwargs['name'] = "CalDAV Server Testing"
233+
kwargs["name"] = "CalDAV Server Testing"
230234
cal = self.principal.make_calendar(**kwargs)
231235
self._default_calendar = cal
232236
return cal
@@ -318,13 +322,13 @@ def check_event(self):
318322
finally:
319323
yearly_time.delete()
320324
yearly_day.delete()
321-
325+
322326
if cal.events():
323327
## Zimbra. Probably related to event_by_url_is_broken
324-
self.set_flag('no_delete_event')
328+
self.set_flag("no_delete_event")
325329
cal = self._fix_cal()
326330
else:
327-
self.set_flag('no_delete_event', False)
331+
self.set_flag("no_delete_event", False)
328332

329333
## Finally, a check that searches involving timespans works as intended
330334
span = cal.add_event(
@@ -336,7 +340,9 @@ def check_event(self):
336340

337341
foo = self._date_search(span, assert_found=False, event=True)
338342
if len(foo) != 0:
339-
import pdb; pdb.set_trace()
343+
import pdb
344+
345+
pdb.set_trace()
340346
raise
341347

342348
span = cal.add_event(
@@ -347,10 +353,10 @@ def check_event(self):
347353
)
348354
ret = self._date_search(span, assert_found=False, event=True)
349355
if ret == [4, 6, 7]:
350-
self.set_flag('date_search_ignores_duration')
356+
self.set_flag("date_search_ignores_duration")
351357
else:
352-
self.set_flag('date_search_ignores_duration', False)
353-
assert len(ret)==0
358+
self.set_flag("date_search_ignores_duration", False)
359+
assert len(ret) == 0
354360

355361
def _check_simple_events(self, obj1, obj2):
356362
cal = self._default_calendar
@@ -511,61 +517,74 @@ def _do_date_search(self, assert_found=True, has_duration=True, **kwargs):
511517
during1 = datetime(2000, 7, 1, 10)
512518
during2 = datetime(2000, 7, 1, 12)
513519
after = datetime(2000, 7, 1, 22)
514-
longafter = datetime(2000, 7, 2, 10)
520+
longafter = datetime(2000, 7, 2, 10)
515521
one_event_lists = [
516522
## open-ended searches, should yield object
517523
cal.search(end=after, **kwargs),
518524
cal.search(start=before, **kwargs),
519-
cal.search(start=before, end=after, **kwargs)
525+
cal.search(start=before, end=after, **kwargs),
520526
]
521527
if has_duration:
522528
## overlapping searches, everything should yield object
523-
one_event_lists.extend([
524-
cal.search(end=during1, **kwargs),
525-
cal.search(start=during1, **kwargs),
526-
cal.search(start=before, end=during1, **kwargs),
527-
cal.search(start=during1, end=during2, **kwargs),
528-
cal.search(start=during1, end=after, **kwargs)
529-
])
529+
one_event_lists.extend(
530+
[
531+
cal.search(end=during1, **kwargs),
532+
cal.search(start=during1, **kwargs),
533+
cal.search(start=before, end=during1, **kwargs),
534+
cal.search(start=during1, end=during2, **kwargs),
535+
cal.search(start=during1, end=after, **kwargs),
536+
]
537+
)
530538
ret = []
531539
for i in range(0, len(one_event_lists)):
532-
if not assert_found and len(one_event_lists[i])==0:
540+
if not assert_found and len(one_event_lists[i]) == 0:
533541
ret.append(i)
534542
else:
535-
assert len(one_event_lists[i])==1
536-
assert(len(cal.search(start=longbefore, end=before))==0)
537-
if kwargs.get('todo'):
538-
if len(cal.search(end=before, **kwargs))==0:
539-
if not 'vtodo_datesearch_nostart_future_tasks_delivered' in self.flags_checked:
540-
self.set_flag('vtodo_datesearch_nostart_future_tasks_delivered', False)
543+
assert len(one_event_lists[i]) == 1
544+
assert len(cal.search(start=longbefore, end=before)) == 0
545+
if kwargs.get("todo"):
546+
if len(cal.search(end=before, **kwargs)) == 0:
547+
if (
548+
not "vtodo_datesearch_nostart_future_tasks_delivered"
549+
in self.flags_checked
550+
):
551+
self.set_flag(
552+
"vtodo_datesearch_nostart_future_tasks_delivered", False
553+
)
541554
else:
542-
self.set_flag('vtodo_datesearch_nostart_future_tasks_delivered', True)
543-
assert len(cal.search(end=before, **kwargs))==1
555+
self.set_flag("vtodo_datesearch_nostart_future_tasks_delivered", True)
556+
assert len(cal.search(end=before, **kwargs)) == 1
544557
else:
545-
assert len(cal.search(end=before, **kwargs))==0
546-
assert(len(cal.search(start=after, end=longafter))==0)
547-
assert(len(cal.search(start=after, **kwargs))==0)
558+
assert len(cal.search(end=before, **kwargs)) == 0
559+
assert len(cal.search(start=after, end=longafter)) == 0
560+
assert len(cal.search(start=after, **kwargs)) == 0
548561
return ret
549562

550563
def check_todo(self):
551564
cal = self._default_calendar
552565
simple = {
553-
'summary': "This is a summary",
554-
'uid': "check_todo_1",
566+
"summary": "This is a summary",
567+
"uid": "check_todo_1",
555568
}
556569
try:
557570
## Add a simplest possible todo
558571
todo_simple = cal.add_todo(**simple)
559572
if not self.flags_checked["object_by_uid_is_broken"]:
560-
assert str(cal.todo_by_uid("check_todo_1").icalendar_component['UID']) == 'check_todo_1'
573+
assert (
574+
str(cal.todo_by_uid("check_todo_1").icalendar_component["UID"])
575+
== "check_todo_1"
576+
)
561577
self.set_flag("no_todo", False)
562578
except Exception as e:
563579
cal = self._fix_cal(todo=True)
564580
try:
565581
## Add a simplest possible todo
566582
todo_simple = cal.add_todo(**simple)
567583
if not self.flags_checked["object_by_uid_is_broken"]:
568-
assert str(cal.todo_by_uid("check_todo_1").icalendar_component['UID']) == 'check_todo_1'
584+
assert (
585+
str(cal.todo_by_uid("check_todo_1").icalendar_component["UID"])
586+
== "check_todo_1"
587+
)
569588
self.set_flag("no_todo", False)
570589
self.set_flag("no_todo_on_standard_calendar")
571590
except:
@@ -587,24 +606,28 @@ def check_todo(self):
587606
dtstart=datetime(2000, 7, 1, 8),
588607
uid="check_todo_2",
589608
)
590-
foobar1 = self._date_search(todo, assert_found=False, has_duration=False, todo=True)
609+
foobar1 = self._date_search(
610+
todo, assert_found=False, has_duration=False, todo=True
611+
)
591612

592613
todo = cal.add_todo(
593614
summary="This has due",
594615
due=datetime(2000, 7, 1, 16),
595616
uid="check_todo_3",
596617
)
597-
foobar2 = self._date_search(todo, assert_found=False, has_duration=False, todo=True)
618+
foobar2 = self._date_search(
619+
todo, assert_found=False, has_duration=False, todo=True
620+
)
598621

599622
todo = cal.add_todo(
600623
summary="This has dtstart and due",
601624
dtstart=datetime(2000, 7, 1, 8),
602625
due=datetime(2000, 7, 1, 16),
603626
uid="check_todo_4",
604627
)
605-
628+
606629
foobar3 = self._date_search(todo, assert_found=False, todo=True)
607-
630+
608631
todo = cal.add_todo(
609632
summary="This has dtstart and dur",
610633
dtstart=datetime(2000, 7, 1, 8),
@@ -615,14 +638,14 @@ def check_todo(self):
615638

616639
if len(foobar1 + foobar2 + foobar3 + foobar4) == 22:
617640
## no todos found
618-
self.set_flag('no_todo_datesearch')
641+
self.set_flag("no_todo_datesearch")
619642
else:
620-
self.set_flag('no_todo_datesearch', False)
643+
self.set_flag("no_todo_datesearch", False)
621644
assert len(foobar1 + foobar2 + foobar3) == 0
622645
if foobar4 == [4, 6, 7]:
623-
self.set_flag('date_todo_search_ignores_duration')
646+
self.set_flag("date_todo_search_ignores_duration")
624647
else:
625-
assert len(foobar4)==0
648+
assert len(foobar4) == 0
626649

627650
def _check_simple_todo(self, todo):
628651
cal = self._default_calendar
@@ -637,50 +660,57 @@ def _check_simple_todo(self, todo):
637660
## I haven't seen that before.
638661
## TODO: add a flag for this
639662
raise
640-
663+
641664
## RFC says that a todo without dtstart/due is
642665
## supposed to span over "infinite time". So itshould always appear
643666
## in date searches.
644667
try:
645-
todos = cal.search(start=datetime(2020,1,1), end=datetime(2020,1,2), todo=True)
646-
assert len(todos) in (0,1)
668+
todos = cal.search(
669+
start=datetime(2020, 1, 1), end=datetime(2020, 1, 2), todo=True
670+
)
671+
assert len(todos) in (0, 1)
647672
self.set_flag("vtodo_datesearch_notime_task_is_skipped", len(todos) == 0)
648673
except Exception as e:
649674
self.set_flag("no_todo_datesearch", True)
650675

651-
def _check_todo_date_search(self, todo_with_dtstart, todo_with_due, todo_with_dtstart_due, todo_with_dtstart_dur):
676+
def _check_todo_date_search(
677+
self,
678+
todo_with_dtstart,
679+
todo_with_due,
680+
todo_with_dtstart_due,
681+
todo_with_dtstart_dur,
682+
):
652683
if self.flag_checked["no_todo_datesearch"]:
653684
return
654685
## Every check below should return one and only one task if
655686
## everything works according to my understanding of the RFC
656687
one_task_lists = []
657688
for start_end in [
658-
## 0 - todo_with_dtstart
659-
((1999, 12, 31, 22, 22, 22),(2000, 1, 1, 0, 30)),
660-
661-
## 1 - todo_with_due
662-
((2000, 1, 1, 0, 30),(2000, 1, 1, 1, 30)),
663-
664-
## 2, 3, 4 - todo_with_dtstart_due
665-
((2000, 1, 1, 1, 30),(2000, 1, 1, 3, 30)),
666-
((2000, 1, 1, 1, 30),(2000, 1, 1, 2, 30)),
667-
((2000, 1, 1, 2, 30),(2000, 1, 1, 3, 30)),
668-
669-
## 5, 6, 7 - todo_with_dtstart_dur
670-
((2000, 1, 1, 3, 30),(2000, 1, 1, 5, 30)),
671-
((2000, 1, 1, 3, 30),(2000, 1, 1, 4, 30)),
672-
((2000, 1, 1, 4, 30),(2000, 1, 1, 5, 30)),
689+
## 0 - todo_with_dtstart
690+
((1999, 12, 31, 22, 22, 22), (2000, 1, 1, 0, 30)),
691+
## 1 - todo_with_due
692+
((2000, 1, 1, 0, 30), (2000, 1, 1, 1, 30)),
693+
## 2, 3, 4 - todo_with_dtstart_due
694+
((2000, 1, 1, 1, 30), (2000, 1, 1, 3, 30)),
695+
((2000, 1, 1, 1, 30), (2000, 1, 1, 2, 30)),
696+
((2000, 1, 1, 2, 30), (2000, 1, 1, 3, 30)),
697+
## 5, 6, 7 - todo_with_dtstart_dur
698+
((2000, 1, 1, 3, 30), (2000, 1, 1, 5, 30)),
699+
((2000, 1, 1, 3, 30), (2000, 1, 1, 4, 30)),
700+
((2000, 1, 1, 4, 30), (2000, 1, 1, 5, 30)),
673701
]:
674-
one_task_lists.append(cal.search(start=datetime(*start_end[0]), end=datetime(*start_end[1])))
702+
one_task_lists.append(
703+
cal.search(start=datetime(*start_end[0]), end=datetime(*start_end[1]))
704+
)
675705

676706
if sum([len(x) for x in one_task_lists]) == 0:
677-
self.set_flag('no_todo_datesearch')
707+
self.set_flag("no_todo_datesearch")
678708
return
679709
else:
680-
self.set_flag('no_todo_datesearch', False)
710+
self.set_flag("no_todo_datesearch", False)
681711

682-
for idx in range(0,8):
683-
if not len(one_task_lists[idx])==1:
712+
for idx in range(0, 8):
713+
if not len(one_task_lists[idx]) == 1:
684714
debugging
685715
pass
686716

tests/compatibility_issues.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192

193193
'date_search_ignores_duration':
194194
"""Date search with search interval overlapping event interval works on events with dtstart and dtend, but not on events with dtstart and due""",
195-
195+
196196
'date_todo_search_ignores_duration':
197197
"""Same as above, but specifically for tasks""",
198198

tests/test_caldav.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ def foo(*a, **kwa):
560560
return f(*a, **kwa)
561561

562562
return foo
563-
563+
564+
564565
class RepeatedFunctionalTestsBaseClass:
565566
"""This is a class with functional tests (tests that goes through
566567
basic functionality and actively communicates with third parties)

0 commit comments

Comments
 (0)