[CalendarServer-changes] [12245] CalendarServer/branches/release/CalendarServer-5.2-dev
source_changes at macosforge.org
source_changes at macosforge.org
Wed Mar 12 11:21:21 PDT 2014
Revision: 12245
http://trac.calendarserver.org//changeset/12245
Author: cdaboo at apple.com
Date: 2014-01-06 16:29:48 -0800 (Mon, 06 Jan 2014)
Log Message:
-----------
Merge from trunk. Allow event splitting at arbitrary recurrence-ids in the future. Add a calverify command to support a manual
split of a specific event.
Modified Paths:
--------------
CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/calverify.py
CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/test/test_calverify.py
CalendarServer/branches/release/CalendarServer-5.2-dev/twistedcaldav/ical.py
CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/icalsplitter.py
CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py
CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/sql.py
Property Changed:
----------------
CalendarServer/branches/release/CalendarServer-5.2-dev/
Property changes on: CalendarServer/branches/release/CalendarServer-5.2-dev
___________________________________________________________________
Modified: svn:mergeinfo
- /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:11898,11991
+ /CalDAVTester/trunk:11193-11198
/CalendarServer/branches/config-separation:4379-4443
/CalendarServer/branches/egg-info-351:4589-4625
/CalendarServer/branches/generic-sqlstore:6167-6191
/CalendarServer/branches/new-store:5594-5934
/CalendarServer/branches/new-store-no-caldavfile:5911-5935
/CalendarServer/branches/new-store-no-caldavfile-2:5936-5981
/CalendarServer/branches/release/CalendarServer-4.3-dev:10180-10190,10192
/CalendarServer/branches/release/CalendarServer-5.1-dev:11846
/CalendarServer/branches/users/cdaboo/batchupload-6699:6700-7198
/CalendarServer/branches/users/cdaboo/cached-subscription-calendars-5692:5693-5702
/CalendarServer/branches/users/cdaboo/component-set-fixes:8130-8346
/CalendarServer/branches/users/cdaboo/directory-cache-on-demand-3627:3628-3644
/CalendarServer/branches/users/cdaboo/fix-no-ischedule:11607-11871
/CalendarServer/branches/users/cdaboo/implicituidrace:8137-8141
/CalendarServer/branches/users/cdaboo/ischedule-dkim:9747-9979
/CalendarServer/branches/users/cdaboo/managed-attachments:9985-10145
/CalendarServer/branches/users/cdaboo/more-sharing-5591:5592-5601
/CalendarServer/branches/users/cdaboo/partition-4464:4465-4957
/CalendarServer/branches/users/cdaboo/performance-tweaks:11824-11836
/CalendarServer/branches/users/cdaboo/pods:7297-7377
/CalendarServer/branches/users/cdaboo/pycalendar:7085-7206
/CalendarServer/branches/users/cdaboo/pycard:7227-7237
/CalendarServer/branches/users/cdaboo/queued-attendee-refreshes:7740-8287
/CalendarServer/branches/users/cdaboo/relative-config-paths-5070:5071-5105
/CalendarServer/branches/users/cdaboo/shared-calendars-5187:5188-5440
/CalendarServer/branches/users/cdaboo/store-scheduling:10876-11129
/CalendarServer/branches/users/cdaboo/timezones:7443-7699
/CalendarServer/branches/users/cdaboo/txn-debugging:8730-8743
/CalendarServer/branches/users/gaya/sharedgroups-3:11088-11204
/CalendarServer/branches/users/glyph/always-abort-txn-on-error:9958-9969
/CalendarServer/branches/users/glyph/case-insensitive-uid:8772-8805
/CalendarServer/branches/users/glyph/conn-limit:6574-6577
/CalendarServer/branches/users/glyph/contacts-server-merge:4971-5080
/CalendarServer/branches/users/glyph/dalify:6932-7023
/CalendarServer/branches/users/glyph/db-reconnect:6824-6876
/CalendarServer/branches/users/glyph/deploybuild:7563-7572
/CalendarServer/branches/users/glyph/digest-auth-redux:10624-10635
/CalendarServer/branches/users/glyph/disable-quota:7718-7727
/CalendarServer/branches/users/glyph/dont-start-postgres:6592-6614
/CalendarServer/branches/users/glyph/enforce-max-requests:11640-11643
/CalendarServer/branches/users/glyph/hang-fix:11465-11491
/CalendarServer/branches/users/glyph/imip-and-admin-html:7866-7984
/CalendarServer/branches/users/glyph/ipv6-client:9054-9105
/CalendarServer/branches/users/glyph/launchd-wrapper-bis:11413-11436
/CalendarServer/branches/users/glyph/linux-tests:6893-6900
/CalendarServer/branches/users/glyph/log-cleanups:11691-11731
/CalendarServer/branches/users/glyph/migrate-merge:8690-8713
/CalendarServer/branches/users/glyph/misc-portability-fixes:7365-7374
/CalendarServer/branches/users/glyph/more-deferreds-6:6322-6368
/CalendarServer/branches/users/glyph/more-deferreds-7:6369-6445
/CalendarServer/branches/users/glyph/multiget-delete:8321-8330
/CalendarServer/branches/users/glyph/new-export:7444-7485
/CalendarServer/branches/users/glyph/one-home-list-api:10048-10073
/CalendarServer/branches/users/glyph/oracle:7106-7155
/CalendarServer/branches/users/glyph/oracle-nulls:7340-7351
/CalendarServer/branches/users/glyph/other-html:8062-8091
/CalendarServer/branches/users/glyph/parallel-sim:8240-8251
/CalendarServer/branches/users/glyph/parallel-upgrade:8376-8400
/CalendarServer/branches/users/glyph/parallel-upgrade_to_1:8571-8583
/CalendarServer/branches/users/glyph/q:9560-9688
/CalendarServer/branches/users/glyph/queue-locking-and-timing:10204-10289
/CalendarServer/branches/users/glyph/quota:7604-7637
/CalendarServer/branches/users/glyph/sendfdport:5388-5424
/CalendarServer/branches/users/glyph/shared-pool-fixes:8436-8443
/CalendarServer/branches/users/glyph/shared-pool-take2:8155-8174
/CalendarServer/branches/users/glyph/sharedpool:6490-6550
/CalendarServer/branches/users/glyph/sharing-api:9192-9205
/CalendarServer/branches/users/glyph/skip-lonely-vtimezones:8524-8535
/CalendarServer/branches/users/glyph/sql-store:5929-6073
/CalendarServer/branches/users/glyph/start-service-start-loop:11060-11065
/CalendarServer/branches/users/glyph/subtransactions:7248-7258
/CalendarServer/branches/users/glyph/table-alias:8651-8664
/CalendarServer/branches/users/glyph/uidexport:7673-7676
/CalendarServer/branches/users/glyph/unshare-when-access-revoked:10562-10595
/CalendarServer/branches/users/glyph/use-system-twisted:5084-5149
/CalendarServer/branches/users/glyph/uuid-normalize:9268-9296
/CalendarServer/branches/users/glyph/warning-cleanups:11347-11357
/CalendarServer/branches/users/glyph/whenNotProposed:11881-11897
/CalendarServer/branches/users/glyph/xattrs-from-files:7757-7769
/CalendarServer/branches/users/sagen/applepush:8126-8184
/CalendarServer/branches/users/sagen/inboxitems:7380-7381
/CalendarServer/branches/users/sagen/locations-resources:5032-5051
/CalendarServer/branches/users/sagen/locations-resources-2:5052-5061
/CalendarServer/branches/users/sagen/purge_old_events:6735-6746
/CalendarServer/branches/users/sagen/resource-delegates-4038:4040-4067
/CalendarServer/branches/users/sagen/resource-delegates-4066:4068-4075
/CalendarServer/branches/users/sagen/resources-2:5084-5093
/CalendarServer/branches/users/sagen/testing:10827-10851,10853-10855
/CalendarServer/branches/users/wsanchez/transations:5515-5593
/CalendarServer/trunk:11898,11991,12241
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/calverify.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/calverify.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/calverify.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -72,6 +72,9 @@
from twistedcaldav.util import normalizationLookup
from txdav.caldav.icalendarstore import ComponentUpdateState
+from txdav.caldav.datastore.scheduling.icalsplitter import iCalSplitter
+from txdav.caldav.datastore.scheduling.implicit import ImplicitScheduler
+from txdav.caldav.datastore.sql import CalendarStoreFeatures
from txdav.common.datastore.sql_tables import schema, _BIND_MODE_OWN
from txdav.common.icommondatastore import InternalDataStoreError
@@ -206,7 +209,7 @@
if not hasattr(Component, "maxAlarmCounts"):
Component.hasDuplicateAlarms = new_hasDuplicateAlarms
-VERSION = "10"
+VERSION = "11"
def printusage(e=None):
if e:
@@ -240,6 +243,7 @@
with either --ical or --mismatch.
--double : detect double-bookings.
--dark-purge : purge room/resource events with invalid organizer
+--split : split recurring event
--nuke PATH|RID : remove specific calendar resources - can
only be used by itself. PATH is the full
@@ -275,6 +279,10 @@
--summary : report only which GUIDs have double-bookings - no details.
--days : number of days ahead to scan [DEFAULT: 365]
+Options for --double:
+If none of (--no-organizer, --invalid-organizer, --disabled-organizer) is present, it
+will default to (--invalid-organizer, --disabled-organizer).
+
Options for --dark-purge:
--uuid : only scan specified calendar homes. Can be a partial GUID
@@ -285,9 +293,12 @@
--invalid-organizer : only detect events with an organizer not in the directory
--disabled-organizer : only detect events with an organizer disabled for calendaring
-If none of (--no-organizer, --invalid-organizer, --disabled-organizer) is present, it
-will default to (--invalid-organizer, --disabled-organizer).
+Options for --split:
+--path : URI path to resource to split.
+--rid : UTC date-time where split occurs (YYYYMMDDTHHMMSSZ).
+--summary : only print a list of recurrences in the resource - no splitting.
+
CHANGES
v8: Detects ORGANIZER or ATTENDEE properties with mailto: calendar user
addresses for users that have valid directory records. Fix is to
@@ -295,6 +306,10 @@
v9: Detects double-bookings.
+v10: Purges data for invalid users.
+
+v11: Allows manual splitting of recurring events.
+
""" % (VERSION,)
@@ -319,10 +334,11 @@
['missing', 'm', "Show 'orphaned' homes."],
['double', 'd', "Detect double-bookings."],
['dark-purge', 'p', "Purge room/resource events with invalid organizer."],
+ ['split', 'l', "Split an event."],
['fix', 'x', "Fix problems."],
['verbose', 'v', "Verbose logging."],
['details', 'V', "Detailed logging."],
- ['summary', 'S', "Summary of double-bookings."],
+ ['summary', 'S', "Summary of double-bookings/split."],
['tzid', 't', "Timezone to adjust displayed times to."],
['no-organizer', '', "Detect dark events without an organizer"],
@@ -335,7 +351,9 @@
['uuid', 'u', "", "Only check this user."],
['uid', 'U', "", "Only this event UID."],
['nuke', 'e', "", "Remove event given its path."],
- ['days', 'T', "365", "Number of days for scanning events into the future."]
+ ['days', 'T', "365", "Number of days for scanning events into the future."],
+ ['path', '', "", "Split event given its path."],
+ ['rid', '', "", "Split date-time."],
]
@@ -2670,6 +2688,122 @@
+class EventSplitService(CalVerifyService):
+ """
+ Service which splits a recurring event at a specific date-time value.
+ """
+
+ def title(self):
+ return "Event Split Service"
+
+
+ @inlineCallbacks
+ def doAction(self):
+ """
+ Split a resource using either its path or resource id.
+ """
+
+ self.txn = self.store.newTransaction()
+
+ path = self.options["path"]
+ if path.startswith("/calendars/__uids__/"):
+ try:
+ pathbits = path.split("/")
+ except TypeError:
+ printusage("Not a valid calendar object resource path: %s" % (path,))
+ if len(pathbits) != 6:
+ printusage("Not a valid calendar object resource path: %s" % (path,))
+ homeName = pathbits[3]
+ calendarName = pathbits[4]
+ resourceName = pathbits[5]
+
+ resid = yield self.getResourceID(homeName, calendarName, resourceName)
+ if resid is None:
+ yield self.txn.commit()
+ self.txn = None
+ self.output.write("\n")
+ self.output.write("Path does not exist. Nothing split.\n")
+ returnValue(None)
+ resid = int(resid)
+ else:
+ try:
+ resid = int(path)
+ except ValueError:
+ printusage("path argument must be a calendar object path or an SQL resource-id")
+
+ calendarObj = yield CalendarStoreFeatures(self.txn._store).calendarObjectWithID(self.txn, resid)
+ ical = yield calendarObj.component()
+
+ # Must be the ORGANIZER's copy
+ organizer = ical.getOrganizer()
+ if organizer is None:
+ printusage("Calendar object has no ORGANIZER property - cannot split")
+
+ # Only allow organizers to split
+ scheduler = ImplicitScheduler()
+ is_attendee = (yield scheduler.testAttendeeEvent(calendarObj.calendar(), calendarObj, ical,))
+ if is_attendee:
+ printusage("Calendar object is not owned by the ORGANIZER - cannot split")
+
+ if self.options["summary"]:
+ result = self.doSummary(ical)
+ else:
+ result = yield self.doSplit(resid, calendarObj, ical)
+
+ returnValue(result)
+
+
+ def doSummary(self, ical):
+ """
+ Print a summary of the recurrence instances of the specified event.
+
+ @param ical: calendar to process
+ @type ical: L{Component}
+ """
+ self.output.write("\n---- Calendar resource instances ----\n")
+
+ # Find the instance RECURRENCE-ID where a split is going to happen
+ now = PyCalendarDateTime.getNowUTC()
+ now.offsetDay(1)
+ instances = ical.cacheExpandedTimeRanges(now)
+ instances = sorted(instances.instances.values(), key=lambda x: x.start)
+ for instance in instances:
+ self.output.write(instance.rid.getText() + (" *\n" if instance.overridden else "\n"))
+
+
+ @inlineCallbacks
+ def doSplit(self, resid, calendarObj, ical):
+ rid = self.options["rid"]
+ try:
+ if rid[-1] != "Z":
+ raise ValueError
+ rid = PyCalendarDateTime.parseText(rid)
+ except ValueError:
+ printusage("rid must be a valid UTC date-time value: 'YYYYMMDDTHHMMSSZ'")
+
+ self.output.write("\n---- Splitting calendar resource ----\n")
+
+ # Find actual RECURRENCE-ID of split
+ splitter = iCalSplitter(1024, 14)
+ rid = splitter.whereSplit(ical, break_point=rid, allow_past_the_end=False)
+ if rid is None:
+ printusage("rid is not a valid recurrence instance")
+
+ self.output.write("\n")
+ self.output.write("Actual RECURRENCE-ID: %s.\n" % (rid,))
+
+ oldUID = yield calendarObj.split(rid=rid)
+
+ self.output.write("\n")
+ self.output.write("Split Resource: %s at %s, old UID: %s.\n" % (resid, rid, oldUID,))
+
+ yield self.txn.commit()
+ self.txn = None
+
+ returnValue(oldUID)
+
+
+
def main(argv=sys.argv, stderr=sys.stderr, reactor=None):
if reactor is None:
@@ -2702,6 +2836,8 @@
return DoubleBookingService(store, options, output, reactor, config)
elif options["dark-purge"]:
return DarkPurgeService(store, options, output, reactor, config)
+ elif options["split"]:
+ return EventSplitService(store, options, output, reactor, config)
else:
printusage("Invalid operation")
sys.exit(1)
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/test/test_calverify.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/test/test_calverify.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/calendarserver/tools/test/test_calverify.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -20,7 +20,8 @@
"""
from calendarserver.tools.calverify import BadDataService, \
- SchedulingMismatchService, DoubleBookingService, DarkPurgeService
+ SchedulingMismatchService, DoubleBookingService, DarkPurgeService, \
+ EventSplitService
from pycalendar.datetime import PyCalendarDateTime
@@ -28,6 +29,7 @@
from twisted.internet.defer import inlineCallbacks
from twistedcaldav.config import config
+from twistedcaldav.ical import normalize_iCalStr
from twistedcaldav.test.util import StoreTestCase
from txdav.common.datastore.test.util import populateCalendarsFrom
@@ -2806,3 +2808,322 @@
self.assertEqual(len(calverify.results["Dark Events"]), 0)
self.assertTrue("Fix dark events" not in calverify.results)
self.assertTrue("Fix remove" not in calverify.results)
+
+
+
+class CalVerifyEventPurge(CalVerifyMismatchTestsBase):
+ """
+ Tests calverify for events.
+ """
+
+ # No organizer
+ NO_ORGANIZER_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20100303T181216Z
+UID:INVITE_NO_ORGANIZER_ICS
+TRANSP:OPAQUE
+SUMMARY:INVITE_NO_ORGANIZER_ICS
+DTSTART:%(now_fwd10)s
+DURATION:PT1H
+DTSTAMP:20100303T181220Z
+SEQUENCE:2
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid organizer
+ VALID_ORGANIZER_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:INVITE_VALID_ORGANIZER_ICS
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RRULE:FREQ=DAILY
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid attendee
+ VALID_ATTENDEE_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:INVITE_VALID_ORGANIZER_ICS
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RRULE:FREQ=DAILY
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid organizer
+ VALID_ORGANIZER_FUTURE_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:INVITE_VALID_ORGANIZER_ICS
+DTSTART:%(now_fwd11)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid attendee
+ VALID_ATTENDEE_FUTURE_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:INVITE_VALID_ORGANIZER_ICS
+DTSTART:%(now_fwd11)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY
+SEQUENCE:1
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid organizer
+ VALID_ORGANIZER_PAST_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:%(relID)s
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY;UNTIL=%(now_fwd11_1)s
+SEQUENCE:1
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid attendee
+ VALID_ATTENDEE_PAST_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:%(relID)s
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY;UNTIL=%(now_fwd11_1)s
+SEQUENCE:1
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ # Valid organizer
+ VALID_ORGANIZER_OVERRIDE_ICS = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//iCal 4.0.1//EN
+BEGIN:VEVENT
+UID:VALID_ORGANIZER_OVERRIDE_ICS
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RRULE:FREQ=DAILY
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+BEGIN:VEVENT
+UID:VALID_ORGANIZER_OVERRIDE_ICS
+RECURRENCE-ID:%(now_fwd11)s
+DTSTART:%(now_fwd11)s
+DURATION:PT2H
+ATTENDEE:urn:uuid:%(uuid1)s
+ATTENDEE:urn:uuid:%(uuid2)s
+ORGANIZER:urn:uuid:%(uuid1)s
+RRULE:FREQ=DAILY
+SUMMARY:INVITE_VALID_ORGANIZER_ICS
+END:VEVENT
+END:VCALENDAR
+""".replace("\n", "\r\n")
+
+ @inlineCallbacks
+ def setUp(self):
+
+ self.subs = {
+ "uuid1" : CalVerifyMismatchTestsBase.uuid1,
+ "uuid2" : CalVerifyMismatchTestsBase.uuid2,
+ }
+
+ self.now = PyCalendarDateTime.getNowUTC()
+ self.now.setHHMMSS(0, 0, 0)
+
+ self.subs["now"] = self.now
+
+ for i in range(30):
+ attrname = "now_back%s" % (i + 1,)
+ setattr(self, attrname, self.now.duplicate())
+ getattr(self, attrname).offsetDay(-(i + 1))
+ self.subs[attrname] = getattr(self, attrname)
+
+ attrname_12h = "now_back%s_12h" % (i + 1,)
+ setattr(self, attrname_12h, getattr(self, attrname).duplicate())
+ getattr(self, attrname_12h).offsetHours(12)
+ self.subs[attrname_12h] = getattr(self, attrname_12h)
+
+ attrname_1 = "now_back%s_1" % (i + 1,)
+ setattr(self, attrname_1, getattr(self, attrname).duplicate())
+ getattr(self, attrname_1).offsetSeconds(-1)
+ self.subs[attrname_1] = getattr(self, attrname_1)
+
+ for i in range(30):
+ attrname = "now_fwd%s" % (i + 1,)
+ setattr(self, attrname, self.now.duplicate())
+ getattr(self, attrname).offsetDay(i + 1)
+ self.subs[attrname] = getattr(self, attrname)
+
+ attrname_12h = "now_fwd%s_12h" % (i + 1,)
+ setattr(self, attrname_12h, getattr(self, attrname).duplicate())
+ getattr(self, attrname_12h).offsetHours(12)
+ self.subs[attrname_12h] = getattr(self, attrname_12h)
+
+ attrname_1 = "now_fwd%s_1" % (i + 1,)
+ setattr(self, attrname_1, getattr(self, attrname).duplicate())
+ getattr(self, attrname_1).offsetSeconds(-1)
+ self.subs[attrname_1] = getattr(self, attrname_1)
+
+ self.requirements = {
+ CalVerifyMismatchTestsBase.uuid1 : {
+ "calendar" : {
+ "invite1.ics" : (self.NO_ORGANIZER_ICS % self.subs, CalVerifyMismatchTestsBase.metadata,),
+ "invite2.ics" : (self.VALID_ORGANIZER_ICS % self.subs, CalVerifyMismatchTestsBase.metadata,),
+ "invite3.ics" : (self.VALID_ORGANIZER_OVERRIDE_ICS % self.subs, CalVerifyMismatchTestsBase.metadata,),
+ },
+ "inbox" : {},
+ },
+ CalVerifyMismatchTestsBase.uuid2 : {
+ "calendar" : {
+ "invite2a.ics" : (self.VALID_ATTENDEE_ICS % self.subs, CalVerifyMismatchTestsBase.metadata,),
+ },
+ "inbox" : {},
+ },
+ CalVerifyMismatchTestsBase.uuid3 : {
+ "calendar" : {},
+ "inbox" : {},
+ },
+ CalVerifyMismatchTestsBase.uuidl1 : {
+ "calendar" : {},
+ "inbox" : {},
+ },
+ }
+
+ yield super(CalVerifyEventPurge, self).setUp()
+
+
+ @inlineCallbacks
+ def test_validSplit(self):
+ """
+ CalVerifyService.doScan without fix for dark events. Make sure it detects
+ as much as it can. Make sure sync-token is not changed.
+ """
+
+ options = {
+ "nuke": False,
+ "missing": False,
+ "ical": False,
+ "mismatch": False,
+ "double": True,
+ "dark-purge": False,
+ "split": True,
+ "path": "/calendars/__uids__/%(uuid1)s/calendar/invite2.ics" % self.subs,
+ "rid": "%(now_fwd11)s" % self.subs,
+ "summary": False,
+ }
+ output = StringIO()
+ calverify = EventSplitService(self._sqlCalendarStore, options, output, reactor, config)
+ oldUID = yield calverify.doAction()
+
+ relsubs = dict(self.subs)
+ relsubs["relID"] = oldUID
+
+ calendar = yield self.calendarUnderTest(home=CalVerifyMismatchTestsBase.uuid1, name="calendar")
+ objs = yield calendar.listObjectResources()
+ self.assertEqual(len(objs), 4)
+ self.assertTrue("invite2.ics" in objs)
+ oldName = filter(lambda x: not x.startswith("invite"), objs)[0]
+
+ obj1 = yield calendar.objectResourceWithName("invite2.ics")
+ ical1 = yield obj1.component()
+ self.assertEqual(normalize_iCalStr(ical1), self.VALID_ORGANIZER_FUTURE_ICS % relsubs)
+
+ obj2 = yield calendar.objectResourceWithName(oldName)
+ ical2 = yield obj2.component()
+ self.assertEqual(normalize_iCalStr(ical2), self.VALID_ORGANIZER_PAST_ICS % relsubs)
+
+ calendar = yield self.calendarUnderTest(home=CalVerifyMismatchTestsBase.uuid2, name="calendar")
+ objs = yield calendar.listObjectResources()
+ self.assertEqual(len(objs), 2)
+ self.assertTrue("invite2a.ics" in objs)
+ oldName = filter(lambda x: not x.startswith("invite"), objs)[0]
+
+ obj1 = yield calendar.objectResourceWithName("invite2a.ics")
+ ical1 = yield obj1.component()
+ self.assertEqual(normalize_iCalStr(ical1), self.VALID_ATTENDEE_FUTURE_ICS % relsubs)
+
+ obj2 = yield calendar.objectResourceWithName(oldName)
+ ical2 = yield obj2.component()
+ self.assertEqual(normalize_iCalStr(ical2), self.VALID_ATTENDEE_PAST_ICS % relsubs)
+
+
+ @inlineCallbacks
+ def test_summary(self):
+ """
+ CalVerifyService.doScan without fix for dark events. Make sure it detects
+ as much as it can. Make sure sync-token is not changed.
+ """
+
+ options = {
+ "nuke": False,
+ "missing": False,
+ "ical": False,
+ "mismatch": False,
+ "double": True,
+ "dark-purge": False,
+ "split": True,
+ "path": "/calendars/__uids__/%(uuid1)s/calendar/invite3.ics" % self.subs,
+ "rid": "%(now_fwd11)s" % self.subs,
+ "summary": True,
+ }
+ output = StringIO()
+ calverify = EventSplitService(self._sqlCalendarStore, options, output, reactor, config)
+ yield calverify.doAction()
+ result = output.getvalue().splitlines()
+ self.assertTrue("%(now)s" % self.subs in result)
+ self.assertTrue("%(now_fwd10)s" % self.subs in result)
+ self.assertTrue("%(now_fwd11)s *" % self.subs in result)
+ self.assertTrue("%(now_fwd12)s" % self.subs in result)
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/twistedcaldav/ical.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/twistedcaldav/ical.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/twistedcaldav/ical.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -3533,7 +3533,7 @@
icalstr = str(icalstr).replace("\r\n ", "")
icalstr = icalstr.replace("\n ", "")
icalstr = "\r\n".join([line for line in icalstr.splitlines() if not line.startswith("DTSTAMP")])
- return icalstr
+ return icalstr + "\r\n"
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/icalsplitter.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/icalsplitter.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/icalsplitter.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -83,17 +83,21 @@
return len(str(ical)) > self.threshold
- def whereSplit(self, ical):
+ def whereSplit(self, ical, break_point=None, allow_past_the_end=True):
"""
Determine where a split is going to happen - i.e., the RECURRENCE-ID.
@param ical: the iCalendar object to test
@type ical: L{Component}
+ @param break_point: the date-time where the break should occur
+ @type break_point: L{DateTime}
@return: recurrence-id of the split
@rtype: L{PyCalendarDateTime}
"""
+ break_point = self.past if break_point is None else break_point
+
# Find the instance RECURRENCE-ID where a split is going to happen
now = self.now.duplicate()
now.offsetDay(1)
@@ -102,13 +106,13 @@
rid = instances[0].rid
for instance in instances:
rid = instance.rid
- if instance.start >= self.past:
+ if instance.start >= break_point:
break
else:
- # We can get here when splitting and event for overrides only in the past,
+ # We can get here when splitting an event for overrides only in the past,
# which happens when splitting an Attendee's copy of an Organizer event
# where the Organizer event has L{willSplit} == C{True}
- rid = self.past
+ rid = break_point if allow_past_the_end else None
return rid
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/scheduling/test/test_icalsplitter.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -63,6 +63,11 @@
getattr(self, attrname_12h).offsetHours(12)
self.subs[attrname_12h] = getattr(self, attrname_12h)
+ attrname_1 = "now_fwd%s_1" % (i + 1,)
+ setattr(self, attrname_1, getattr(self, attrname).duplicate())
+ getattr(self, attrname_1).offsetSeconds(-1)
+ self.subs[attrname_1] = getattr(self, attrname_1)
+
self.patch(config, "MaxAllowedInstances", 500)
@@ -2018,3 +2023,188 @@
# Make sure new items won't split again
self.assertFalse(splitter.willSplit(icalNew), "Failed future will split: %s" % (title,))
self.assertFalse(splitter.willSplit(icalOld), "Failed past will split: %s" % (title,))
+
+
+ def test_future_split(self):
+
+ data = (
+ (
+ "1.1 - RRULE with override",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ATTENDEE:mailto:user3 at example.com
+ATTENDEE:mailto:user4 at example.com
+ATTENDEE:mailto:user5 at example.com
+ATTENDEE:mailto:user6 at example.com
+ATTENDEE:mailto:user7 at example.com
+ATTENDEE:mailto:user8 at example.com
+ATTENDEE:mailto:user9 at example.com
+ATTENDEE:mailto:user10 at example.com
+ATTENDEE:mailto:user11 at example.com
+ATTENDEE:mailto:user12 at example.com
+ATTENDEE:mailto:user13 at example.com
+ATTENDEE:mailto:user14 at example.com
+ATTENDEE:mailto:user15 at example.com
+ATTENDEE:mailto:user16 at example.com
+ATTENDEE:mailto:user17 at example.com
+ATTENDEE:mailto:user18 at example.com
+ATTENDEE:mailto:user19 at example.com
+ATTENDEE:mailto:user20 at example.com
+ATTENDEE:mailto:user21 at example.com
+ATTENDEE:mailto:user22 at example.com
+ATTENDEE:mailto:user23 at example.com
+ATTENDEE:mailto:user24 at example.com
+ATTENDEE:mailto:user25 at example.com
+ORGANIZER:mailto:user1 at example.com
+RRULE:FREQ=DAILY
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_fwd10)s
+DTSTART:%(now_fwd10)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_fwd11)s
+DTSTART:%(now_fwd11)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:%(now_fwd11)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ATTENDEE:mailto:user3 at example.com
+ATTENDEE:mailto:user4 at example.com
+ATTENDEE:mailto:user5 at example.com
+ATTENDEE:mailto:user6 at example.com
+ATTENDEE:mailto:user7 at example.com
+ATTENDEE:mailto:user8 at example.com
+ATTENDEE:mailto:user9 at example.com
+ATTENDEE:mailto:user10 at example.com
+ATTENDEE:mailto:user11 at example.com
+ATTENDEE:mailto:user12 at example.com
+ATTENDEE:mailto:user13 at example.com
+ATTENDEE:mailto:user14 at example.com
+ATTENDEE:mailto:user15 at example.com
+ATTENDEE:mailto:user16 at example.com
+ATTENDEE:mailto:user17 at example.com
+ATTENDEE:mailto:user18 at example.com
+ATTENDEE:mailto:user19 at example.com
+ATTENDEE:mailto:user20 at example.com
+ATTENDEE:mailto:user21 at example.com
+ATTENDEE:mailto:user22 at example.com
+ATTENDEE:mailto:user23 at example.com
+ATTENDEE:mailto:user24 at example.com
+ATTENDEE:mailto:user25 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY
+END:VEVENT
+BEGIN:VEVENT
+UID:12345-67890
+RECURRENCE-ID:%(now_fwd11)s
+DTSTART:%(now_fwd11)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+END:VEVENT
+END:VCALENDAR
+""",
+ """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:%(relID)s
+DTSTART:%(now)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ATTENDEE:mailto:user3 at example.com
+ATTENDEE:mailto:user4 at example.com
+ATTENDEE:mailto:user5 at example.com
+ATTENDEE:mailto:user6 at example.com
+ATTENDEE:mailto:user7 at example.com
+ATTENDEE:mailto:user8 at example.com
+ATTENDEE:mailto:user9 at example.com
+ATTENDEE:mailto:user10 at example.com
+ATTENDEE:mailto:user11 at example.com
+ATTENDEE:mailto:user12 at example.com
+ATTENDEE:mailto:user13 at example.com
+ATTENDEE:mailto:user14 at example.com
+ATTENDEE:mailto:user15 at example.com
+ATTENDEE:mailto:user16 at example.com
+ATTENDEE:mailto:user17 at example.com
+ATTENDEE:mailto:user18 at example.com
+ATTENDEE:mailto:user19 at example.com
+ATTENDEE:mailto:user20 at example.com
+ATTENDEE:mailto:user21 at example.com
+ATTENDEE:mailto:user22 at example.com
+ATTENDEE:mailto:user23 at example.com
+ATTENDEE:mailto:user24 at example.com
+ATTENDEE:mailto:user25 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+RRULE:FREQ=DAILY;UNTIL=%(now_fwd11_1)s
+END:VEVENT
+BEGIN:VEVENT
+UID:%(relID)s
+RECURRENCE-ID:%(now_fwd10)s
+DTSTART:%(now_fwd10)s
+DURATION:PT1H
+ATTENDEE:mailto:user1 at example.com
+ATTENDEE:mailto:user2 at example.com
+ORGANIZER:mailto:user1 at example.com
+RELATED-TO;RELTYPE=X-CALENDARSERVER-RECURRENCE-SET:%(relID)s
+END:VEVENT
+END:VCALENDAR
+""",
+ ),
+ )
+
+ for title, calendar, split_future, split_past in data:
+ ical = Component.fromString(calendar % self.subs)
+ splitter = iCalSplitter(1024, 14)
+ icalOld, icalNew = splitter.split(ical, rid=PyCalendarDateTime.parseText("%(now_fwd11)s" % self.subs))
+ relsubs = dict(self.subs)
+ relsubs["relID"] = icalOld.resourceUID()
+ self.assertEqual(str(icalNew).replace("\r\n ", ""), split_future.replace("\n", "\r\n") % relsubs, "Failed future: %s" % (title,))
+ self.assertEqual(str(icalOld).replace("\r\n ", ""), split_past.replace("\n", "\r\n") % relsubs, "Failed past: %s" % (title,))
+
+ # Make sure new items won't split again
+ self.assertFalse(splitter.willSplit(icalNew), "Failed future will split: %s" % (title,))
+ self.assertFalse(splitter.willSplit(icalOld), "Failed past will split: %s" % (title,))
+
+ ical = Component.fromString(calendar % self.subs)
+ splitter = iCalSplitter(1024, 14)
+ icalOld, icalNew = splitter.split(ical, rid=splitter.whereSplit(ical, break_point=PyCalendarDateTime.parseText("%(now_fwd10_12h)s" % self.subs)))
+ relsubs = dict(self.subs)
+ relsubs["relID"] = icalOld.resourceUID()
+ self.assertEqual(str(icalNew).replace("\r\n ", ""), split_future.replace("\n", "\r\n") % relsubs, "Failed future: %s" % (title,))
+ self.assertEqual(str(icalOld).replace("\r\n ", ""), split_past.replace("\n", "\r\n") % relsubs, "Failed past: %s" % (title,))
+
+ # Make sure new items won't split again
+ self.assertFalse(splitter.willSplit(icalNew), "Failed future will split: %s" % (title,))
+ self.assertFalse(splitter.willSplit(icalOld), "Failed past will split: %s" % (title,))
Modified: CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/sql.py
===================================================================
--- CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/sql.py 2014-01-06 23:22:43 UTC (rev 12244)
+++ CalendarServer/branches/release/CalendarServer-5.2-dev/txdav/caldav/datastore/sql.py 2014-01-07 00:29:48 UTC (rev 12245)
@@ -358,7 +358,7 @@
@inlineCallbacks
def calendarObjectWithID(self, txn, rid):
"""
- Return all child object resources with the specified UID. Only "owned" resources are returned,
+ Return all child object resources with the specified resource id. Only "owned" resources are returned,
no shared resources.
@param txn: transaction to use
@@ -370,7 +370,7 @@
@rtype: L{CalendarObject} or C{None}
"""
- # First find the resource-ids of the (home, parent, object) for each object matching the UID.
+ # First find the resource-ids of the (home, parent, object) for each object matching the resource id.
obj = CalendarHome._objectSchema
bind = CalendarHome._bindSchema
rows = (yield Select(
@@ -3331,6 +3331,8 @@
if will:
notBefore = datetime.datetime.utcnow() + datetime.timedelta(seconds=config.Scheduling.Options.Splitting.Delay)
work = (yield self._txn.enqueue(CalendarObject.CalendarObjectSplitterWork, resourceID=self._resourceID, notBefore=notBefore))
+
+ # _workItems is used during unit testing only, to track the created work
if not hasattr(self, "_workItems"):
self._workItems = []
self._workItems.append(work)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/886735b7/attachment.html>
More information about the calendarserver-changes
mailing list