summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-02-10 09:44:05 +0100
committerThomas Bruederli <bruederli@kolabsys.com>2015-02-10 09:44:05 +0100
commita214f29290f4d5e5a2d62a8a549679c8a4c0fe51 (patch)
tree5808111ed8491357b7e362b7ad5c79c096ac1172
parent21c116a670c3a34a1e084e1af7c75541a1783f27 (diff)
downloadpykolab-a214f29290f4d5e5a2d62a8a549679c8a4c0fe51.tar.gz
Fix iCal event parsing + unit tests after commit 21c116a
-rw-r--r--pykolab/xml/event.py10
-rw-r--r--tests/unit/test-003-event.py6
2 files changed, 9 insertions, 7 deletions
diff --git a/pykolab/xml/event.py b/pykolab/xml/event.py
index b179b8f..cb2b876 100644
--- a/pykolab/xml/event.py
+++ b/pykolab/xml/event.py
@@ -260,9 +260,9 @@ class Event(object):
self.event.setAttendees(self._attendees)
def from_ical(self, ical, raw=None):
- if isinstance(ical, icalendar.Todo):
- ical_todo = ical
- if hasattr(icalendar.Event, 'from_ical'):
+ if isinstance(ical, icalendar.Event) or isinstance(ical_event, icalendar.Calendar):
+ ical_event = ical
+ elif hasattr(icalendar.Event, 'from_ical'):
ical_event = icalendar.Event.from_ical(ical)
elif hasattr(icalendar.Event, 'from_string'):
ical_event = icalendar.Event.from_string(ical)
@@ -300,9 +300,11 @@ class Event(object):
self.set_from_ical(attr.lower(), ical_event[attr])
def _xml_from_ical(self, ical):
+ if not "BEGIN:VCALENDAR" in ical:
+ ical = "BEGIN:VCALENDAR\nVERSION:2.0\n" + ical + "\nEND:VCALENDAR"
from kolab.calendaring import EventCal
self.event = EventCal()
- self.event.fromICal("BEGIN:VCALENDAR\nVERSION:2.0\n" + ical + "\nEND:VCALENDAR")
+ self.event.fromICal(ical)
def get_attendee_participant_status(self, attendee):
return attendee.get_participant_status()
diff --git a/tests/unit/test-003-event.py b/tests/unit/test-003-event.py
index 02bc8df..67481e3 100644
--- a/tests/unit/test-003-event.py
+++ b/tests/unit/test-003-event.py
@@ -369,7 +369,7 @@ METHOD:REQUEST
""" + ical_event + "END:VCALENDAR"
ical = icalendar.Calendar.from_ical(ical_str)
- event = event_from_ical(ical.walk('VEVENT')[0].to_ical())
+ event = event_from_ical(ical.walk('VEVENT')[0], ical_str)
self.assertEqual(event.get_location(), "Location")
self.assertEqual(str(event.get_lastmodified()), "2014-04-07 12:23:11+00:00")
@@ -384,7 +384,7 @@ METHOD:REQUEST
self.assertTrue(event.is_recurring())
self.assertIsInstance(event.get_duration(), datetime.timedelta)
self.assertIsInstance(event.get_end(), datetime.datetime)
- self.assertEqual(str(event.get_end()), "2014-05-23 12:30:00+01:00")
+ self.assertEqual(str(event.get_end()), "2014-05-23 12:30:00+02:00")
self.assertEqual(len(event.get_exception_dates()), 2)
self.assertIsInstance(event.get_exception_dates()[0], datetime.datetime)
self.assertEqual(len(event.get_alarms()), 1)
@@ -632,7 +632,7 @@ END:VEVENT
self.assertEqual(data['attach'][0]['fmttype'], 'text/html')
self.assertIsInstance(data['rrule'], dict)
- self.assertEqual(data['rrule']['frequency'], 'DAILY')
+ self.assertEqual(data['rrule']['freq'], 'DAILY')
self.assertEqual(data['rrule']['interval'], 1)
self.assertEqual(data['rrule']['wkst'], 'MO')
self.assertIsInstance(data['rrule']['until'], datetime.date)