-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for tasks (vtodo) elements. Closes #59
- Loading branch information
1 parent
210efd1
commit 0c32c51
Showing
4 changed files
with
161 additions
and
17 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 |
---|---|---|
|
@@ -29,6 29,7 @@ class TestItemsFeed(ICalFeed): | |
def items(self): | ||
return [ | ||
{ | ||
"component_type": "event", | ||
"title": "Title1", | ||
"description": "Description1", | ||
"link": "/event/1", | ||
|
@@ -73,6 74,7 @@ def items(self): | |
"modified": datetime(2012, 5, 2, 10, 0), | ||
}, | ||
{ | ||
"component_type": "event", | ||
"title": "Title2", | ||
"description": "Description2", | ||
"link": "/event/2", | ||
|
@@ -108,8 110,31 @@ def items(self): | |
}, | ||
], | ||
}, | ||
{ | ||
"component_type": "todo", | ||
"title": "Submit Revised Internet-Draft", | ||
"description": "an important test", | ||
"link": "/event/3", | ||
"start": datetime(2007, 5, 14, 0), | ||
"due": datetime(2007, 5, 16, 0), | ||
"completed": datetime(2007, 3, 20), | ||
"priority": 1, | ||
"status": "NEEDS-ACTION", | ||
"organizer": { | ||
"cn": "Bossy Martin", | ||
"email": "[email protected]", | ||
"role": "CHAIR" | ||
}, | ||
"modified": datetime(2012, 5, 2, 10, 0), | ||
"geolocation": (37.386013, 2.238985), | ||
"categories": ['CLEANING'], | ||
"percent_complete": 89, | ||
}, | ||
] | ||
|
||
def item_component_type(self, obj): | ||
return obj.get("component_type", None) | ||
|
||
def item_title(self, obj): | ||
return obj["title"] | ||
|
||
|
@@ -120,19 145,22 @@ def item_start_datetime(self, obj): | |
return obj["start"] | ||
|
||
def item_end_datetime(self, obj): | ||
return obj["end"] | ||
return obj.get("end", None) | ||
|
||
def item_due_datetime(self, obj): | ||
return obj.get("due", None) | ||
|
||
def item_rrule(self, obj): | ||
return obj["recurrences"]["rrules"] | ||
return obj.get("recurrences", {}).get("rrules", None) | ||
|
||
def item_exrule(self, obj): | ||
return obj["recurrences"]["xrules"] | ||
return obj.get("recurrences", {}).get("xrules", None) | ||
|
||
def item_rdate(self, obj): | ||
return obj["recurrences"]["rdates"] | ||
return obj.get("recurrences", {}).get("rdates", None) | ||
|
||
def item_exdate(self, obj): | ||
return obj["recurrences"]["xdates"] | ||
return obj.get("recurrences", {}).get("xdates", None) | ||
|
||
def item_link(self, obj): | ||
return obj["link"] | ||
|
@@ -146,6 174,21 @@ def item_updateddate(self, obj): | |
def item_pubdate(self, obj): | ||
return obj.get("modified", None) | ||
|
||
def item_completed(self, obj): | ||
return obj.get("completed", None) | ||
|
||
def item_percent_complete(self, obj): | ||
return obj.get("percent_complete", None) | ||
|
||
def item_priority(self, obj): | ||
return obj.get("priority", None) | ||
|
||
def item_due(self, obj): | ||
return obj.get("due", None) | ||
|
||
def item_categories(self, obj): | ||
return obj.get("categories") or [] | ||
|
||
def item_organizer(self, obj): | ||
organizer_dic = obj.get("organizer", None) | ||
if organizer_dic: | ||
|
@@ -230,7 273,7 @@ def test_items(self): | |
response = view(request) | ||
|
||
calendar = icalendar.Calendar.from_ical(response.content) | ||
self.assertEqual(len(calendar.subcomponents), 2) | ||
self.assertEqual(len(calendar.subcomponents), 3) | ||
|
||
self.assertEqual(calendar.subcomponents[0]["SUMMARY"], "Title1") | ||
self.assertEqual(calendar.subcomponents[0]["DESCRIPTION"], "Description1") | ||
|
@@ -342,6 385,34 @@ def test_items(self): | |
[comp.to_ical() for comp in calendar.subcomponents[1].subcomponents], | ||
) | ||
|
||
self.assertEqual(calendar.subcomponents[2]["SUMMARY"], "Submit Revised Internet-Draft") | ||
self.assertTrue(calendar.subcomponents[2]["URL"].endswith("/event/3")) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["DTSTART"].to_ical(), b"20070514T000000" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["DUE"].to_ical(), b"20070516T000000" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["GEO"].to_ical(), "37.386013;2.238985" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["LAST-MODIFIED"].to_ical(), b"20120502T100000Z" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["ORGANIZER"].to_ical(), | ||
b"MAILTO:[email protected]", | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["PRIORITY"].to_ical(), b"1" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["CATEGORIES"][0].to_ical(), b"CLEANING" | ||
) | ||
self.assertEqual( | ||
calendar.subcomponents[2]["PERCENT-COMPLETE"].to_ical(), b"89" | ||
) | ||
|
||
def test_wr_timezone(self): | ||
""" | ||
Test for the x-wr-timezone property. | ||
|
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