[CalendarServer-changes] [11657] CalendarServer/trunk/txdav

source_changes at macosforge.org source_changes at macosforge.org
Fri Sep 6 11:07:48 PDT 2013


Revision: 11657
          http://trac.calendarserver.org//changeset/11657
Author:   cdaboo at apple.com
Date:     2013-09-06 11:07:48 -0700 (Fri, 06 Sep 2013)
Log Message:
-----------
Make sure batch attendee refresh works.

Modified Paths:
--------------
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
    CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py
    CalendarServer/trunk/txdav/common/datastore/sql.py

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2013-09-06 14:35:51 UTC (rev 11656)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/processing.py	2013-09-06 18:07:48 UTC (rev 11657)
@@ -359,7 +359,7 @@
             # refresh them. To prevent a race we need a lock.
             yield NamedLock.acquire(txn, "ImplicitUIDLock:%s" % (hashlib.md5(self.uid).hexdigest(),))
 
-            organizer_home = (yield txn.calendarHomeForUID(self.organizer_uid))
+            organizer_home = (yield txn.calendarHomeWithUID(self.organizer_uid))
             organizer_resource = (yield organizer_home.objectResourceWithID(self.organizer_calendar_resource_id))
             if organizer_resource is not None:
                 yield self._doRefresh(organizer_resource, only_attendees=attendeesToProcess)

Modified: CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py	2013-09-06 14:35:51 UTC (rev 11656)
+++ CalendarServer/trunk/txdav/caldav/datastore/scheduling/test/test_implicit.py	2013-09-06 18:07:48 UTC (rev 11657)
@@ -21,10 +21,12 @@
 from twext.web2 import responsecode
 from twext.web2.http import HTTPError
 
+from twisted.internet import reactor
 from twisted.internet.defer import succeed, inlineCallbacks, returnValue
+from twisted.internet.task import deferLater
 from twisted.trial.unittest import TestCase
+
 from twistedcaldav.config import config
-
 from twistedcaldav.ical import Component
 
 from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
@@ -1412,3 +1414,91 @@
 
         calendar3 = (yield self._getCalendarData("user03"))
         self.assertTrue("PARTSTAT=ACCEPTED" in calendar3)
+
+
+    @inlineCallbacks
+    def test_doImplicitScheduling_refreshAllAttendeesExceptSome_Batched(self):
+        """
+        Test that doImplicitScheduling delivers scheduling messages to attendees who can then reply.
+        Verify that batched refreshing is working.
+        """
+
+        data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+        data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+ATTENDEE:mailto:user03 at example.com
+END:VEVENT
+END:VCALENDAR
+"""
+
+        # Need refreshes to occur immediately, not via reactor.callLater
+        self.patch(config.Scheduling.Options, "AttendeeRefreshBatch", 5)
+        self.patch(config.Scheduling.Options, "AttendeeRefreshBatchDelaySeconds", 1)
+
+        yield self._createCalendarObject(data1, "user01", "test.ics")
+
+        list1 = (yield self._listCalendarObjects("user01", "inbox"))
+        self.assertEqual(len(list1), 0)
+
+        calendar1 = (yield self._getCalendarData("user01", "test.ics"))
+        self.assertTrue("SCHEDULE-STATUS=1.2" in calendar1)
+
+        list2 = (yield self._listCalendarObjects("user02", "inbox"))
+        self.assertEqual(len(list2), 1)
+
+        calendar2 = (yield self._getCalendarData("user02"))
+        self.assertTrue("PARTSTAT=ACCEPTED" not in calendar2)
+
+        list3 = (yield self._listCalendarObjects("user03", "inbox"))
+        self.assertEqual(len(list3), 1)
+
+        calendar3 = (yield self._getCalendarData("user03"))
+        self.assertTrue("PARTSTAT=ACCEPTED" not in calendar3)
+
+        yield self._setCalendarData(data2, "user02")
+
+        list1 = (yield self._listCalendarObjects("user01", "inbox"))
+        self.assertEqual(len(list1), 1)
+
+        calendar1 = (yield self._getCalendarData("user01", "test.ics"))
+        self.assertTrue("SCHEDULE-STATUS=2.0" in calendar1)
+        self.assertTrue("PARTSTAT=ACCEPTED" in calendar1)
+
+        list2 = (yield self._listCalendarObjects("user02", "inbox"))
+        self.assertEqual(len(list2), 1)
+
+        calendar2 = (yield self._getCalendarData("user02"))
+        self.assertTrue("PARTSTAT=ACCEPTED" in calendar2)
+
+        @inlineCallbacks
+        def _test_user03_refresh():
+            list3 = (yield self._listCalendarObjects("user03", "inbox"))
+            self.assertEqual(len(list3), 1)
+
+            calendar3 = (yield self._getCalendarData("user03"))
+            self.assertTrue("PARTSTAT=ACCEPTED" in calendar3)
+
+        yield deferLater(reactor, 2.0, _test_user03_refresh)

Modified: CalendarServer/trunk/txdav/common/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/common/datastore/sql.py	2013-09-06 14:35:51 UTC (rev 11656)
+++ CalendarServer/trunk/txdav/common/datastore/sql.py	2013-09-06 18:07:48 UTC (rev 11657)
@@ -550,14 +550,6 @@
         ).on(self)
 
 
-    def calendarHomeWithUID(self, uid, create=False):
-        return self.homeWithUID(ECALENDARTYPE, uid, create=create)
-
-
-    def addressbookHomeWithUID(self, uid, create=False):
-        return self.homeWithUID(EADDRESSBOOKTYPE, uid, create=create)
-
-
     def _determineMemo(self, storeType, uid, create=False): #@UnusedVariable
         """
         Determine the memo dictionary to use for homeWithUID.
@@ -591,6 +583,14 @@
         return self._homeClass[storeType].homeWithUID(self, uid, create)
 
 
+    def calendarHomeWithUID(self, uid, create=False):
+        return self.homeWithUID(ECALENDARTYPE, uid, create=create)
+
+
+    def addressbookHomeWithUID(self, uid, create=False):
+        return self.homeWithUID(EADDRESSBOOKTYPE, uid, create=create)
+
+
     @inlineCallbacks
     def homeWithResourceID(self, storeType, rid, create=False):
         """
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130906/22c88734/attachment.html>


More information about the calendarserver-changes mailing list