[CalendarServer-changes] [14977] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 16 18:24:43 PDT 2015
Revision: 14977
http://trac.calendarserver.org//changeset/14977
Author: cdaboo at apple.com
Date: 2015-07-16 18:24:43 -0700 (Thu, 16 Jul 2015)
Log Message:
-----------
Fix exception with missing sharer when fixing VTODOs.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-16 19:53:36 UTC (rev 14976)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2015-07-17 01:24:43 UTC (rev 14977)
@@ -3182,7 +3182,10 @@
# Get the originator who is the owner of the calendar resource being modified
originatorPrincipal = yield self.calendar().ownerHome().directoryRecord()
- originatorAddresses = originatorPrincipal.calendarUserAddresses
+ if originatorPrincipal is not None:
+ originatorAddresses = originatorPrincipal.calendarUserAddresses
+ else:
+ originatorAddresses = ("urn:x-uid:{}".format(self.calendar().ownerHome().uid),)
for component in calendar.subcomponents():
if component.name() != "VTODO":
@@ -3219,7 +3222,10 @@
# Get the originator who is the owner of the calendar resource being modified
originatorPrincipal = yield self.calendar().ownerHome().directoryRecord()
- originatorAddresses = originatorPrincipal.calendarUserAddresses
+ if originatorPrincipal is not None:
+ originatorAddresses = originatorPrincipal.calendarUserAddresses
+ else:
+ originatorAddresses = ("urn:x-uid:{}".format(self.calendar().ownerHome().uid),)
for component in calendar.subcomponents():
if component.name() != "VTODO":
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-16 19:53:36 UTC (rev 14976)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2015-07-17 01:24:43 UTC (rev 14977)
@@ -58,7 +58,7 @@
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_DIRECT, \
_BIND_STATUS_ACCEPTED, _TRANSP_OPAQUE, _BIND_MODE_WRITE
from txdav.caldav.datastore.test.common import CommonTests as CalendarCommonTests, \
- test_event_text, cal1Root
+ test_event_text, cal1Root, OTHER_HOME_UID
from txdav.caldav.datastore.test.test_file import setUpCalendarStore
from txdav.caldav.datastore.test.util import DateTimeSubstitutionsMixin
from txdav.common.datastore.test.util import populateCalendarsFrom, \
@@ -2209,7 +2209,72 @@
yield self.commit()
+ @inlineCallbacks
+ def test_sharedTasksMissingSharer(self):
+ """
+ Make sure that a sharee can store tasks when the sharer has been removed from
+ the directory.
+ """
+ home = yield self.homeUnderTest()
+ cal = yield home.createCalendarWithName("shared_tasks")
+ yield cal.setSupportedComponents("VTODO")
+ yield self.commit()
+ cal = yield self.calendarUnderTest(name="shared_tasks")
+ other = yield self.homeUnderTest(name=OTHER_HOME_UID)
+ newCalName = yield cal.shareWith(other, _BIND_MODE_WRITE)
+ self.sharedName = newCalName
+ yield self.commit()
+
+ cal = yield self.calendarUnderTest(name="shared_tasks")
+ yield cal.createCalendarObjectWithName("data1.ics", Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+SUMMARY:original
+END:VTODO
+END:VCALENDAR
+"""))
+ yield self.commit()
+
+ yield self._sqlCalendarStore.directoryService().removeRecords(((yield self.userUIDFromShortName("home1")),))
+
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name=self.sharedName, home=OTHER_HOME_UID)
+ yield cobj.setComponent(Component.fromString("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+COMPLETED:20080601T130000Z
+SUMMARY:changed
+END:VTODO
+END:VCALENDAR
+"""))
+ yield self.commit()
+
+ cobj = yield self.calendarObjectUnderTest(name="data1.ics", calendar_name=self.sharedName, home=OTHER_HOME_UID)
+ comp = yield cobj.componentForUser()
+ self.assertEqual(normalize_iCalStr(comp), normalize_iCalStr("""BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VTODO
+UID:12345-67890-attendee-reply
+DTSTAMP:20080601T120000Z
+DTSTART:20080601T120000Z
+COMPLETED:20080601T130000Z
+SUMMARY:changed
+END:VTODO
+END:VCALENDAR
+"""))
+ yield self.commit()
+
+
+
class SyncTests(CommonCommonTests, unittest.TestCase):
"""
Revision table/sync report tests.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150716/b24e768b/attachment-0001.html>
More information about the calendarserver-changes
mailing list