summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pykolab/xml/event.py7
-rw-r--r--tests/unit/test-003-event.py21
2 files changed, 27 insertions, 1 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index f2a51e6..508dabb 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()