-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #181 from jabiertxof/fixIssue75
Add RECURRENCE-ID with range parameter.
- Loading branch information
Showing
5 changed files
with
162 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
BEGIN:VCALENDAR | ||
VERSION:2.0 | ||
PRODID:RESERVAS 1.0//EN | ||
BEGIN:VEVENT | ||
UID:210 | ||
DTSTART:20240901T120000Z | ||
DTEND:20240901T140000Z | ||
RRULE:FREQ=DAILY;INTERVAL=2;UNTIL=20250920 | ||
RDATE:20240924T090000Z | ||
SEQUENCE:0 | ||
SUMMARY:ORIGINAL EVENT | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:210 | ||
RECURRENCE-ID;RANGE=THISANDFUTURE:20240913T120000Z | ||
DTSTART:20240913T090000Z | ||
DTEND:20240913T160000Z | ||
SEQUENCE:1 | ||
SUMMARY:MODIFIED EVENT | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:210 | ||
RECURRENCE-ID:20240915T120000Z | ||
DTSTART:20240915T170000Z | ||
DTEND:20240915T190000Z | ||
SEQUENCE:1 | ||
SUMMARY:MODIFIED EVENT | ||
END:VEVENT | ||
BEGIN:VEVENT | ||
UID:210 | ||
RECURRENCE-ID;RANGE=THISANDFUTURE:20240922T120000Z | ||
DTSTART:20240922T142200Z | ||
DTEND:20240922T161300Z | ||
SEQUENCE:1 | ||
SUMMARY:EDITED EVENT | ||
END:VEVENT | ||
END:VCALENDAR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# shim for pylib going away | ||
# if pylib is installed this file will get skipped | ||
# (`py/__init__.py` has higher precedence) | ||
from __future__ import annotations | ||
|
||
import sys | ||
|
||
import _pytest._py.error as error | ||
import _pytest._py.path as path | ||
|
||
|
||
sys.modules["py.error"] = error | ||
sys.modules["py.path"] = path | ||
|
||
__all__ = ["error", "path"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
"""This tests the range parameter for ics file. | ||
see https://github.com/niccokunzmann/python-recurring-ical-events/issues/75 | ||
Description: This parameter can be specified on a property that | ||
specifies a recurrence identifier. The parameter specifies the | ||
effective range of recurrence instances that is specified by the | ||
property. The effective range is from the recurrence identifier | ||
specified by the property. If this parameter is not specified on | ||
an allowed property, then the default range is the single instance | ||
specified by the recurrence identifier value of the property. The | ||
parameter value can only be "THISANDFUTURE" to indicate a range | ||
defined by the recurrence identifier and all subsequent instances. | ||
The value "THISANDPRIOR" is deprecated by this revision of | ||
iCalendar and MUST NOT be generated by applications. | ||
""" | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("date", "summary"), | ||
[ | ||
("20240901", "ORIGINAL EVENT"), | ||
("20240911", "ORIGINAL EVENT"), | ||
("20240913", "MODIFIED EVENT"), | ||
("20240915", "MODIFIED EVENT"), # Normal recurrence-id | ||
("20240917", "MODIFIED EVENT"), | ||
("20240919", "MODIFIED EVENT"), | ||
("20240921", "MODIFIED EVENT"), | ||
("20240922", "EDITED EVENT"), | ||
("20240924", "EDITED EVENT"), # RDATE | ||
("20240925", "EDITED EVENT"), | ||
], | ||
) | ||
def test_issue_75_RANGE_AT_parameter(calendars, date, summary): | ||
events = calendars.issue_75_range_parameter.at(date) | ||
assert len(events) == 1, f"Expecting one event at {date}" | ||
event = events[0] | ||
assert str(event["SUMMARY"]) == summary | ||
|
||
@pytest.mark.parametrize( | ||
("start", "end", "summary","total"), | ||
[ | ||
("20240901T000000Z", "20240911T235959Z", "ORIGINAL EVENT",6), | ||
("20240901T000000Z", "20240913T000000Z", "ORIGINAL EVENT",6), | ||
("20240901T000000Z", "20240913T235959Z", "MODIFIED EVENT",7), | ||
("20240901T000000Z", "20240915T235959Z", "MODIFIED EVENT",8), # Normal recurrence-id | ||
("20240901T000000Z", "20240917T235959Z", "MODIFIED EVENT",9), | ||
("20240901T000000Z", "20240919T235959Z", "MODIFIED EVENT",10), | ||
("20240901T000000Z", "20240921T235959Z", "MODIFIED EVENT",11), | ||
("20240901T000000Z", "20240922T000000Z", "MODIFIED EVENT",11), | ||
("20240901T000000Z", "20240922T235959Z", "EDITED EVENT",12), | ||
("20240901T000000Z", "20240923T000000Z", "EDITED EVENT",12), | ||
("20240901T000000Z", "20240923T235959Z", "EDITED EVENT",13), | ||
("20240901T000000Z", "20240924T235959Z", "EDITED EVENT",14), # RDATE | ||
("20240901T000000Z", "20240925T235959Z", "EDITED EVENT",15), | ||
("20240913T000000Z", "20240922T000000Z", "MODIFIED EVENT",5), # out of query bounds | ||
("20240913T000000Z", "20240922T235959Z", "EDITED EVENT",6), # out of query bounds | ||
("20240924T000000Z", "20240925T235959Z", "EDITED EVENT",2), # out of query bounds | ||
], | ||
) | ||
def test_issue_75_RANGE_BETWEEN_parameter(calendars, start, end, summary, total): | ||
events = calendars.issue_75_range_parameter.between(start,end) | ||
assert len(events) == total, f"Expecting {total} events at range {start}, {end}, get {len(events)}" | ||
event = events[-1] | ||
assert str(event["SUMMARY"]) == summary | ||
|
||
# TODO: Test DTSTART and DTEND |