Skip to content

Commit

Permalink
check of recurrence id is present
Browse files Browse the repository at this point in the history
- fixes #15
  • Loading branch information
niccokunzmann committed Oct 14, 2019
1 parent b4c4d05 commit f4a90b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions recurring_ical_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,15 @@ def between(self, start, stop): # TODO: add parameters from time_span_contains_e
def add_event(event):
"""Add an event and check if it was edited."""
same_events = events_by_id[event.get("UID", default_uid)] # TODO: test what comes first
recurrence_id = event.get("RECURRENCE-ID", event["DTSTART"]).dt
recurrence_id = event.get("RECURRENCE-ID", event["DTSTART"]).dt # TODO: this is still wrong: what if there are different events at the same time?
other = same_events.get(recurrence_id, None)
if other: # TODO: test that this is independet of order
if event["SEQUENCE"] < other["SEQUENCE"]:
return
events.remove(other)
event_sequence = event.get("SEQUENCE", None)
other_sequence = other.get("SEQUENCE", None)
if event_sequence is not None and other_sequence is not None:
if event["SEQUENCE"] < other["SEQUENCE"]:
return
events.remove(other)
same_events[recurrence_id] = event
events.append(event)

Expand Down
2 changes: 1 addition & 1 deletion test/test_issue_15.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ def test_rdate_does_not_double_rrule_entry(calendars):

def test_sequence_is_not_present(calendars):
events = calendars.issue_15_duplicated_events.at("20130803")
assert len(events) == 1
assert len(events) == 3

0 comments on commit f4a90b2

Please sign in to comment.