pykolab/xml tests/unit
Thomas Brüderli
bruederli at kolabsys.com
Tue Feb 25 10:03:37 CET 2014
pykolab/xml/event.py | 7 ++++++-
tests/unit/test-003-event.py | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
New commits:
commit 8a271d60bab1e4d7aece7c42805484dc10a6bf41
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Tue Feb 25 10:03:16 2014 +0100
Fix importing CUTYPE parameters from iCal
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index 9145a45..9bbbaca 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -686,7 +686,12 @@ class Event(object):
else:
rsvp = None
- self.add_attendee(address, name=name, rsvp=rsvp, role=role, participant_status=partstat)
+ if params.has_key('CUTYPE'):
+ cutype = params['CUTYPE']
+ else:
+ cutype = kolabformat.CutypeIndividual
+
+ self.add_attendee(address, name=name, rsvp=rsvp, role=role, participant_status=partstat, cutype=cutype)
def set_ical_dtend(self, dtend):
self.set_end(dtend)
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 1a38fad..1da272a 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -3,12 +3,14 @@ import pytz
import sys
import unittest
import kolabformat
+import icalendar
from pykolab.xml import Attendee
from pykolab.xml import Event
from pykolab.xml import EventIntegrityError
from pykolab.xml import InvalidAttendeeParticipantStatusError
from pykolab.xml import InvalidEventDateError
+from pykolab.xml import event_from_ical
class TestEventXML(unittest.TestCase):
event = Event()
@@ -112,5 +114,24 @@ class TestEventXML(unittest.TestCase):
self.assertEqual(hasattr(_start,'tzinfo'), False)
self.assertEqual(self.event.get_start().__str__(), "2012-05-23")
+ def test_018_from_ical_cutype(self):
+ ical_str = """BEGIN:VCALENDAR
+VERSION:2.0
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+DTSTART;TZID=Europe/Zurich;VALUE=DATE-TIME:20140523T110000
+DTEND;TZID=Europe/Zurich;VALUE=DATE-TIME:20140523T130000
+UID:7a35527d-f783-4b58-b404-b1389bd2fc57
+ATTENDEE;CN="Doe, Jane";CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED
+ ;ROLE=REQ-PARTICIPANT;RSVP=FALSE:MAILTO:jane at doe.org
+ATTENDEE;CUTYPE=RESOURCE;PARTSTAT=NEEDS-ACTION
+ ;ROLE=OPTIONAL;RSVP=FALSE:MAILTO:max at imum.com
+END:VEVENT
+END:VCALENDAR
+"""
+ ical = icalendar.Calendar.from_ical(ical_str)
+ event = event_from_ical(ical.walk('VEVENT')[0].to_ical())
+ self.assertEqual(event.get_attendee_by_email("max at imum.com").get_cutype(), kolabformat.CutypeResource)
+
if __name__ == '__main__':
unittest.main()
More information about the commits
mailing list