[CalendarServer-changes] [15192] CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav /datastore/scheduling/imip

source_changes at macosforge.org source_changes at macosforge.org
Thu Oct 15 11:53:04 PDT 2015


Revision: 15192
          http://trac.calendarserver.org//changeset/15192
Author:   cdaboo at apple.com
Date:     2015-10-15 11:53:04 -0700 (Thu, 15 Oct 2015)
Log Message:
-----------
Fix failure to send iMIP messages.

Modified Paths:
--------------
    CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/delivery.py
    CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py

Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/delivery.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/delivery.py	2015-10-14 18:40:31 UTC (rev 15191)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/delivery.py	2015-10-15 18:53:04 UTC (rev 15192)
@@ -103,19 +103,20 @@
                     log.debug("Submitting iMIP message...  To: '%s', From :'%s'\n%s" % (toAddr, fromAddr, caldata,))
 
                     def enqueueOp(txn):
-                        return txn.enqueue(IMIPInvitationWork, fromAddr=fromAddr,
-                            toAddr=toAddr, icalendarText=caldata)
+                        return txn.enqueue(
+                            IMIPInvitationWork, fromAddr=fromAddr,
+                            toAddr=toAddr, icalendarText=caldata
+                        )
 
                     yield inTransaction(
-                        lambda: self.scheduler.txn.store().newTransaction(
-                            "Submitting iMIP message for UID: %s" % (
-                            self.scheduler.calendar.resourceUID(),)),
-                        enqueueOp
+                        self.scheduler.txn.store().newTransaction,
+                        enqueueOp,
+                        label="Submitting iMIP message for UID: %s" % (self.scheduler.calendar.resourceUID(),)
                     )
 
                 except Exception, e:
                     # Generated failed response for this recipient
-                    log.debug("iMIP request %s failed for recipient %s: %s" % (self, recipient, e))
+                    log.error("iMIP request %s failed for recipient %s: %s" % (self, recipient, e))
                     failForRecipient(recipient)
 
                 else:
@@ -127,6 +128,6 @@
 
         except Exception, e:
             # Generated failed responses for each recipient
-            log.debug("iMIP request %s failed: %s" % (self, e))
+            log.error("iMIP request %s failed: %s" % (self, e))
             for recipient in self.recipients:
                 failForRecipient(recipient)

Modified: CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py	2015-10-14 18:40:31 UTC (rev 15191)
+++ CalendarServer/branches/release/CalendarServer-5.4-dev/txdav/caldav/datastore/scheduling/imip/test/test_delivery.py	2015-10-15 18:53:04 UTC (rev 15192)
@@ -16,25 +16,50 @@
 
 from twext.web2 import responsecode
 
-from twisted.internet.defer import inlineCallbacks
+from twisted.internet.defer import inlineCallbacks, succeed
 from twisted.trial import unittest
 
 from twistedcaldav.config import config
 from twistedcaldav.ical import Component
 
-from txdav.caldav.datastore.scheduling.cuaddress import RemoteCalendarUser
+from txdav.caldav.datastore.scheduling.cuaddress import RemoteCalendarUser, \
+    LocalCalendarUser
 from txdav.caldav.datastore.scheduling.imip.delivery import ScheduleViaIMip
 from txdav.caldav.datastore.scheduling.itip import iTIPRequestStatus
 from txdav.caldav.datastore.scheduling.scheduler import ScheduleResponseQueue
+from txdav.caldav.datastore.scheduling.imip.outbound import IMIPInvitationWork
+from txdav.common.datastore.test.util import CommonCommonTests
+from txdav.caldav.datastore.test.util import buildCalendarStore
 
-class iMIPProcessing (unittest.TestCase):
+class iMIPProcessing (CommonCommonTests, unittest.TestCase):
     """
     iCalendar support tests
     """
 
+    @inlineCallbacks
+    def setUp(self):
+        yield super(iMIPProcessing, self).setUp()
+        self._sqlCalendarStore = yield buildCalendarStore(self, self.notifierFactory)
+
+        self.wp = None
+        self._sqlCalendarStore.queuer.callWithNewProposals(self._proposalCallback)
+
+
+    def _proposalCallback(self, wp):
+        self.wp = wp
+
+
+    def storeUnderTest(self):
+        """
+        Create and return a L{CalendarStore} for testing.
+        """
+        return self._sqlCalendarStore
+
+
     class FakeSchedule(object):
 
-        def __init__(self, calendar):
+        def __init__(self, originator, calendar):
+            self.originator = originator
             self.calendar = calendar
 
 
@@ -56,7 +81,10 @@
 END:VCALENDAR
 """
 
-        scheduler = iMIPProcessing.FakeSchedule(Component.fromString(data))
+        scheduler = iMIPProcessing.FakeSchedule(
+            LocalCalendarUser("mailto:user1 at example.com", None),
+            Component.fromString(data)
+        )
         recipients = (RemoteCalendarUser("mailto:user1 at example.com"),)
         responses = ScheduleResponseQueue("REQUEST", responsecode.OK)
 
@@ -68,6 +96,51 @@
 
 
     @inlineCallbacks
+    def test_iMIP_delivery(self):
+
+        data = """BEGIN:VCALENDAR
+VERSION:2.0
+METHOD:REQUEST
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:20080601T120000Z
+DTEND:20080601T130000Z
+ORGANIZER;CN="User 01":mailto:user1 at example.com
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.org
+END:VEVENT
+END:VCALENDAR
+"""
+
+        results = []
+        class FakeSender(object):
+            def outbound(self, txn, fromAddr, toAddr, calendar):
+                results.append((fromAddr, toAddr))
+                return succeed(None)
+        self.patch(IMIPInvitationWork, "mailSender", FakeSender())
+
+        scheduler = iMIPProcessing.FakeSchedule(
+            LocalCalendarUser("mailto:user1 at example.com", None),
+            Component.fromString(data)
+        )
+        scheduler.txn = self.transactionUnderTest()
+        recipients = (RemoteCalendarUser("mailto:user2 at example.org"),)
+        responses = ScheduleResponseQueue("REQUEST", responsecode.OK)
+
+        delivery = ScheduleViaIMip(scheduler, recipients, responses, False)
+        yield delivery.generateSchedulingResponses()
+
+        self.assertEqual(len(responses.responses), 1)
+        self.assertEqual(str(responses.responses[0].children[1]), iTIPRequestStatus.MESSAGE_SENT)
+
+        yield self.wp.whenExecuted()
+
+        self.assertEqual(len(results), 1)
+        self.assertEqual(results[0], ("mailto:user1 at example.com", "mailto:user2 at example.org",))
+
+
+    @inlineCallbacks
     def test_matchCalendarUserAddress(self):
         # iMIP not sensitive to case:
         self.patch(config.Scheduling[ScheduleViaIMip.serviceType()], "AddressPatterns", ["mailto:.*"])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20151015/60ab9445/attachment.html>


More information about the calendarserver-changes mailing list