[CalendarServer-changes] [8415] CalendarServer/trunk/txdav/caldav/datastore
source_changes at macosforge.org
source_changes at macosforge.org
Wed Dec 7 20:08:40 PST 2011
Revision: 8415
http://trac.macosforge.org/projects/calendarserver/changeset/8415
Author: cdaboo at apple.com
Date: 2011-12-07 20:08:38 -0800 (Wed, 07 Dec 2011)
Log Message:
-----------
Make sure that when we split collections during an upgrade or migration that we are left with at least one
collection for each component type.
Modified Paths:
--------------
CalendarServer/trunk/txdav/caldav/datastore/sql.py
CalendarServer/trunk/txdav/caldav/datastore/test/common.py
CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
Added Paths:
-----------
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/1.ics
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/2.ics
CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/3.ics
Modified: CalendarServer/trunk/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/sql.py 2011-12-08 02:04:21 UTC (rev 8414)
+++ CalendarServer/trunk/txdav/caldav/datastore/sql.py 2011-12-08 04:08:38 UTC (rev 8415)
@@ -82,6 +82,8 @@
from zope.interface.declarations import implements
+import uuid
+
class CalendarHome(CommonHome):
implements(ICalendarHome)
@@ -248,6 +250,30 @@
split_count = yield calendar.splitCollectionByComponentTypes()
self.log_warn(" Calendar: '%s', split into %d" % (calendar.name(), split_count+1,))
+ # Double check that we have calendars supporting at least VEVENT and VTODO
+ if config.RestrictCalendarsToOneComponentType:
+ supported_components = set()
+ names = set()
+ calendars = yield self.calendars()
+ for calendar in calendars:
+ if calendar.name() == "inbox":
+ continue
+ names.add(calendar.name())
+ result = yield calendar.getSupportedComponents()
+ supported_components.update(result.split(","))
+
+ @inlineCallbacks
+ def _requireCalendarWithType(support_component, tryname):
+ if support_component not in supported_components:
+ newname = tryname
+ if newname in names:
+ newname = str(uuid.uuid4())
+ newcal = yield self.createCalendarWithName(newname)
+ newcal.setSupportedComponents(support_component)
+
+ yield _requireCalendarWithType("VEVENT", "calendar")
+ yield _requireCalendarWithType("VTODO", "tasks")
+
class Calendar(CommonHomeChild):
"""
File-based implementation of L{ICalendar}.
Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/1.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/1.ics (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/1.ics 2011-12-08 04:08:38 UTC (rev 8415)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0800
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:PDT
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0700
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:PST
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTEND;TZID=US/Pacific:20090324T124500
+UID:uid1
+DTSTAMP:20090326T145447Z
+X-APPLE-DROPBOX:/calendars/__uids__/user01/dropbox/uid1.dropbox
+ATTACH;VALUE=URI:/calendars/__uids__/user01/dropbox/uid1.dropbox/test.txt
+SUMMARY:CalDAV protocol updates
+DTSTART;TZID=US/Pacific:20090324T121500
+CREATED:20090326T145440Z
+END:VEVENT
+END:VCALENDAR
Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/2.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/2.ics (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/2.ics 2011-12-08 04:08:38 UTC (rev 8415)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0800
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:PDT
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0700
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:PST
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTEND;TZID=US/Pacific:20090324T124500
+UID:uid2
+DTSTAMP:20090326T145447Z
+X-APPLE-DROPBOX:/calendars/__uids__/user01/dropbox/uid2.dropbox
+ATTACH;VALUE=URI:/calendars/__uids__/user01/dropbox/uid2.dropbox/test.txt
+SUMMARY:CalDAV protocol updates
+DTSTART;TZID=US/Pacific:20090324T121500
+CREATED:20090326T145440Z
+END:VEVENT
+END:VCALENDAR
Added: CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/3.ics
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/3.ics (rev 0)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/calendar_store/ho/me/home_no_splits/calendar_1/3.ics 2011-12-08 04:08:38 UTC (rev 8415)
@@ -0,0 +1,32 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:US/Pacific
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0800
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:PDT
+TZOFFSETTO:-0700
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0700
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:PST
+TZOFFSETTO:-0800
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+DTEND;TZID=US/Pacific:20090324T124500
+UID:uid3
+DTSTAMP:20090326T145447Z
+X-APPLE-DROPBOX:/calendars/__uids__/user01/dropbox/uid2.dropbox
+ATTACH;VALUE=URI:/calendars/__uids__/user01/dropbox/uid2.dropbox/test.txt
+SUMMARY:CalDAV protocol updates
+DTSTART;TZID=US/Pacific:20090324T121500
+CREATED:20090326T145440Z
+END:VEVENT
+END:VCALENDAR
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/common.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-12-08 02:04:21 UTC (rev 8414)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/common.py 2011-12-08 04:08:38 UTC (rev 8415)
@@ -68,6 +68,9 @@
cal1SplitsRoot = homeSplitsRoot.child("calendar_1")
cal2SplitsRoot = homeSplitsRoot.child("calendar_2")
+homeNoSplitsRoot = storePath.child("ho").child("me").child("home_no_splits")
+cal1NoSplitsRoot = homeNoSplitsRoot.child("calendar_1")
+
calendar1_objectNames = [
"1.ics",
"2.ics",
@@ -254,6 +257,13 @@
"5.ics": (cal2SplitsRoot.child("5.ics").getContent(), metadata4),
},
},
+ "home_no_splits": {
+ "calendar_1": {
+ "1.ics": (cal1NoSplitsRoot.child("1.ics").getContent(), metadata1),
+ "2.ics": (cal1NoSplitsRoot.child("2.ics").getContent(), metadata2),
+ "3.ics": (cal1NoSplitsRoot.child("3.ics").getContent(), metadata3),
+ },
+ },
"home_splits_shared": {
"calendar_1": {},
},
@@ -285,6 +295,13 @@
"5.ics": md5Values[4],
},
},
+ "home_no_splits": {
+ "calendar_1": {
+ "1.ics": md5Values[0],
+ "2.ics": md5Values[1],
+ "3.ics": md5Values[2],
+ },
+ },
}
Modified: CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py
===================================================================
--- CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2011-12-08 02:04:21 UTC (rev 8414)
+++ CalendarServer/trunk/txdav/caldav/datastore/test/test_sql.py 2011-12-08 04:08:38 UTC (rev 8415)
@@ -832,3 +832,29 @@
self.assertEqual(sorted(deleted), ["3.ics", "5.ics"])
result = yield calendar2.getSupportedComponents()
self.assertEquals(result, "VEVENT")
+
+ @inlineCallbacks
+ def test_noSplitCalendars(self):
+ """
+ Test CalendarHome.splitCalendars to make sure we end up with at least two collections
+ with different supported components.
+ """
+
+ # Do split
+ home = yield self.transactionUnderTest().calendarHomeWithUID("home_no_splits")
+ calendars = yield home.calendars()
+ self.assertEqual(len(calendars), 1)
+ yield home.splitCalendars()
+ yield self.commit()
+
+ # Make sure we have calendars supporting both VEVENT and VTODO
+ home = yield self.transactionUnderTest().calendarHomeWithUID("home_no_splits")
+ supported_components = set()
+ calendars = yield home.calendars()
+ for calendar in calendars:
+ if calendar.name() == "inbox":
+ continue
+ result = yield calendar.getSupportedComponents()
+ supported_components.add(result)
+
+ self.assertEqual(supported_components, set(("VEVENT", "VTODO",)))
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20111207/92af7391/attachment.html>
More information about the calendarserver-changes
mailing list