[CalendarServer-changes] [11583] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Tue Aug 6 11:37:59 PDT 2013
Revision: 11583
http://trac.calendarserver.org//changeset/11583
Author: cdaboo at apple.com
Date: 2013-08-06 11:37:59 -0700 (Tue, 06 Aug 2013)
Log Message:
-----------
Make sure attendee fix behavior works correctly.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py 2013-08-06 15:07:50 UTC (rev 11582)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py 2013-08-06 18:37:59 UTC (rev 11583)
@@ -1066,7 +1066,7 @@
# We only need to fix data that already exists
if recipient_resource is not None:
if originator_calendar.mainType() != None:
- yield self.writeCalendarResource(recipient_resource, originator_calendar)
+ yield self.writeCalendarResource(None, recipient_resource, originator_calendar)
else:
yield self.deleteCalendarResource(recipient_resource)
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2013-08-06 15:07:50 UTC (rev 11582)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2013-08-06 18:37:59 UTC (rev 11583)
@@ -20,6 +20,7 @@
from txdav.caldav.datastore.scheduling.scheduler import ScheduleResponseQueue
from twext.web2 import responsecode
from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
+from twistedcaldav.instance import InvalidOverriddenInstanceError
"""
Tests for txdav.caldav.datastore.postgres, mostly based on
@@ -29,7 +30,8 @@
from pycalendar.datetime import PyCalendarDateTime
from pycalendar.timezone import PyCalendarTimezone
-from twext.enterprise.dal.syntax import Select, Parameter, Insert, Delete
+from twext.enterprise.dal.syntax import Select, Parameter, Insert, Delete, \
+ Update
from twext.python.vcomponent import VComponent
from twext.web2.http_headers import MimeType
from twext.web2.stream import MemoryStream
@@ -1950,6 +1952,189 @@
+class SchedulingTests(CommonCommonTests, unittest.TestCase):
+ """
+ CalendarObject splitting tests
+ """
+
+ @inlineCallbacks
+ def setUp(self):
+ yield super(SchedulingTests, self).setUp()
+ self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
+
+ # Make sure homes are provisioned
+ txn = self.transactionUnderTest()
+ for ctr in range(1, 5):
+ home_uid = yield txn.homeWithUID(ECALENDARTYPE, "user%02d" % (ctr,), create=True)
+ self.assertNotEqual(home_uid, None)
+ yield self.commit()
+
+
+ @inlineCallbacks
+ def populate(self):
+ yield populateCalendarsFrom(self.requirements, self.storeUnderTest())
+ self.notifierFactory.reset()
+
+
+ def storeUnderTest(self):
+ """
+ Create and return a L{CalendarStore} for testing.
+ """
+ return self._sqlCalendarStore
+
+
+ @inlineCallbacks
+ def test_doImplicitAttendeeEventFix(self):
+ """
+ Test that processing.doImplicitAttendeeEventFix.
+ """
+
+ data = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20130806T000000Z
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01 at example.com
+RRULE:FREQ=DAILY
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data_broken = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20130806T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+RRULE:FREQ=DAILY
+SUMMARY:1
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20130807T120000Z
+DTSTART:20130807T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data_update1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20130806T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:1-2
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20130807T000000Z
+DTSTART:20130807T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+SEQUENCE:1
+SUMMARY:1-3
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data_fixed2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20130806T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:1-2
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:20130807T000000Z
+DTSTART:20130807T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01 at example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02 at example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01 at example.com:urn:uuid:user01
+SEQUENCE:1
+SUMMARY:1-3
+END:VEVENT
+BEGIN:X-CALENDARSERVER-PERUSER
+UID:12345-67890
+X-CALENDARSERVER-PERUSER-UID:user02
+BEGIN:X-CALENDARSERVER-PERINSTANCE
+TRANSP:TRANSPARENT
+END:X-CALENDARSERVER-PERINSTANCE
+END:X-CALENDARSERVER-PERUSER
+END:VCALENDAR
+"""
+
+ # Create one event
+ calendar = yield self.calendarUnderTest(name="calendar", home="user01")
+ yield calendar.createCalendarObjectWithName("data1.ics", Component.fromString(data))
+ yield self.commit()
+
+ # Write corrupt user02 data directly to trigger fix later
+ cal = yield self.calendarUnderTest(name="calendar", home="user02")
+ cobjs = yield cal.calendarObjects()
+ self.assertEqual(len(cobjs), 1)
+ cobj = cobjs[0]
+ name02 = cobj.name()
+ co = schema.CALENDAR_OBJECT
+ yield Update(
+ {co.ICALENDAR_TEXT: str(Component.fromString(data_broken))},
+ Where=co.RESOURCE_NAME == name02,
+ ).on(self.transactionUnderTest())
+ yield self.commit()
+
+ # Write user01 data - will trigger fix
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name="calendar", home="user01")
+ yield cobj.setComponent(Component.fromString(data_update1))
+ yield self.commit()
+
+ # Verify user02 data is now fixed
+ cobj = yield self.calendarObjectUnderTest(name=name02, calendar_name="calendar", home="user02")
+ ical = yield cobj.component()
+
+ self.assertEqual(normalize_iCalStr(ical), normalize_iCalStr(data_fixed2), "Failed attendee fix:\n%s" % (diff_iCalStrs(ical, data_fixed2),))
+ yield self.commit()
+
+ self.assertEqual(len(self.flushLoggedErrors(InvalidOverriddenInstanceError)), 1)
+
+
+
class CalendarObjectSplitting(CommonCommonTests, unittest.TestCase):
"""
CalendarObject splitting tests
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130806/51b2dce2/attachment-0001.html>
More information about the calendarserver-changes
mailing list