diff options
author | Thomas Bruederli <bruederli@kolabsys.com> | 2014-02-25 10:03:16 +0100 |
---|---|---|
committer | Thomas Bruederli <bruederli@kolabsys.com> | 2014-02-25 10:03:16 +0100 |
commit | 8a271d60bab1e4d7aece7c42805484dc10a6bf41 (patch) | |
tree | 018786330bd84756d07d9a9c3140735a24b9d04f | |
parent | f64c8d5e4162ccd034e4ab8fe7a3760b0282d1f0 (diff) | |
download | pykolab-8a271d60bab1e4d7aece7c42805484dc10a6bf41.tar.gz |
Fix importing CUTYPE parameters from iCal
-rw-r--r-- | pykolab/xml/event.py | 7 | ||||
-rw-r--r-- | tests/unit/test-003-event.py | 21 |
2 files changed, 27 insertions, 1 deletions
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@doe.org +ATTENDEE;CUTYPE=RESOURCE;PARTSTAT=NEEDS-ACTION + ;ROLE=OPTIONAL;RSVP=FALSE:MAILTO:max@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@imum.com").get_cutype(), kolabformat.CutypeResource) + if __name__ == '__main__': unittest.main() |