<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[12468] CalendarServer/branches/users/cdaboo/scheduling-queue-refresh</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.calendarserver.org//changeset/12468">12468</a></dd>
<dt>Author</dt> <dd>cdaboo@apple.com</dd>
<dt>Date</dt> <dd>2014-01-28 17:45:15 -0800 (Tue, 28 Jan 2014)</dd>
</dl>
<h3>Log Message</h3>
<pre>Checkpoint: tests for queued invite/reply (and fix reply).</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdabooschedulingqueuerefreshtwistedcaldavicalpy">CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcaldavdatastoreschedulingworkpy">CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/work.py</a></li>
<li><a href="#CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcommondatastoretestutilpy">CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/common/datastore/test/util.py</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcaldavdatastoretesttest_queue_schedulingpy">CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/test/test_queue_scheduling.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServerbranchesuserscdabooschedulingqueuerefreshtwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/twistedcaldav/ical.py (12467 => 12468)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/twistedcaldav/ical.py        2014-01-28 19:56:12 UTC (rev 12467)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/twistedcaldav/ical.py        2014-01-29 01:45:15 UTC (rev 12468)
</span><span class="lines">@@ -3652,7 +3652,12 @@
</span><span class="cx">
</span><span class="cx"> icalstr = str(icalstr).replace("\r\n ", "")
</span><span class="cx"> icalstr = icalstr.replace("\n ", "")
</span><del>- icalstr = "\r\n".join([line for line in icalstr.splitlines() if not line.startswith("DTSTAMP")])
</del><ins>+ lines = [line for line in icalstr.splitlines() if not line.startswith("DTSTAMP")]
+ for ctr, line in enumerate(lines[:]):
+ pos = line.find(";X-CALENDARSERVER-DTSTAMP=")
+ if pos != -1:
+ lines[ctr] = line[:pos] + line[pos + len(";X-CALENDARSERVER-DTSTAMP=") + 16:]
+ icalstr = "\r\n".join(lines)
</ins><span class="cx"> return icalstr + "\r\n"
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcaldavdatastoreschedulingworkpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/work.py (12467 => 12468)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/work.py        2014-01-28 19:56:12 UTC (rev 12467)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/scheduling/work.py        2014-01-29 01:45:15 UTC (rev 12468)
</span><span class="lines">@@ -22,7 +22,6 @@
</span><span class="cx">
</span><span class="cx"> from twisted.internet.defer import inlineCallbacks, returnValue, Deferred
</span><span class="cx">
</span><del>-from twistedcaldav import caldavxml
</del><span class="cx"> from twistedcaldav.config import config
</span><span class="cx"> from twistedcaldav.ical import Component
</span><span class="cx">
</span><span class="lines">@@ -33,6 +32,7 @@
</span><span class="cx">
</span><span class="cx"> import datetime
</span><span class="cx"> import hashlib
</span><ins>+from pycalendar.datetime import DateTime
</ins><span class="cx">
</span><span class="cx"> __all__ = [
</span><span class="cx"> "ScheduleOrganizerWork",
</span><span class="lines">@@ -49,10 +49,44 @@
</span><span class="cx"> Base class for common schedule work item behavior.
</span><span class="cx"> """
</span><span class="cx">
</span><ins>+ # Track when all work is complete (needed for unit tests)
+ _allDoneCallback = None
+ _queued = 0
+
</ins><span class="cx"> # Schedule work is grouped based on calendar object UID
</span><span class="cx"> group = property(lambda self: "ScheduleWork:%s" % (self.icalendarUid,))
</span><span class="cx">
</span><span class="cx">
</span><ins>+ @classmethod
+ def allDone(cls):
+ d = Deferred()
+ cls._allDoneCallback = d.callback
+ cls._queued = 0
+ return d
+
+
+ @classmethod
+ def _enqueued(cls):
+ """
+ Called when a new item is enqueued - using for tracking purposes.
+ """
+ ScheduleWorkMixin._queued += 1
+
+
+ def _dequeued(self):
+ """
+ Called when an item is dequeued - using for tracking purposes. We call
+ the callback when the last item is dequeued.
+ """
+ ScheduleWorkMixin._queued -= 1
+ if ScheduleWorkMixin._queued == 0:
+ if ScheduleWorkMixin._allDoneCallback:
+ def _post():
+ ScheduleWorkMixin._allDoneCallback(None)
+ ScheduleWorkMixin._allDoneCallback = None
+ self.transaction.postCommit(_post)
+
+
</ins><span class="cx"> @inlineCallbacks
</span><span class="cx"> def handleSchedulingResponse(self, response, calendar, resource, is_organizer):
</span><span class="cx"> """
</span><span class="lines">@@ -73,10 +107,10 @@
</span><span class="cx">
</span><span class="cx"> # Map each recipient in the response to a status code
</span><span class="cx"> changed = False
</span><ins>+ propname = calendar.mainComponent().recipientPropertyName() if is_organizer else "ORGANIZER"
</ins><span class="cx"> for item in response.responses:
</span><del>- assert isinstance(item, caldavxml.Response), "Wrong element in response"
- recipient = str(item.children[0].children[0])
- status = str(item.children[1])
</del><ins>+ recipient = str(item.recipient.children[0])
+ status = str(item.reqstatus)
</ins><span class="cx"> statusCode = status.split(";")[0]
</span><span class="cx">
</span><span class="cx"> # Now apply to each ATTENDEE/ORGANIZER in the original data only if not 1.2
</span><span class="lines">@@ -84,7 +118,7 @@
</span><span class="cx"> calendar.setParameterToValueForPropertyWithValue(
</span><span class="cx"> "SCHEDULE-STATUS",
</span><span class="cx"> statusCode,
</span><del>- "ATTENDEE" if is_organizer else "ORGANIZER",
</del><ins>+ propname,
</ins><span class="cx"> recipient,
</span><span class="cx"> )
</span><span class="cx"> changed = True
</span><span class="lines">@@ -102,8 +136,6 @@
</span><span class="cx"> their calendar object resource.
</span><span class="cx"> """
</span><span class="cx">
</span><del>- _allDoneCallback = None
-
</del><span class="cx"> @classmethod
</span><span class="cx"> @inlineCallbacks
</span><span class="cx"> def schedule(cls, txn, uid, action, home, resource, calendar, organizer, smart_merge):
</span><span class="lines">@@ -129,6 +161,7 @@
</span><span class="cx"> icalendarText=calendar.getTextWithTimezones(includeTimezones=not config.EnableTimezonesByReference) if calendar else None,
</span><span class="cx"> smartMerge=smart_merge
</span><span class="cx"> ))
</span><ins>+ cls._enqueued()
</ins><span class="cx"> yield proposal.whenProposed()
</span><span class="cx"> log.debug("ScheduleOrganizerWork - enqueued for ID: {id}, UID: {uid}, organizer: {org}", id=proposal.workItem.workID, uid=uid, org=organizer)
</span><span class="cx">
</span><span class="lines">@@ -144,13 +177,6 @@
</span><span class="cx"> returnValue(len(rows) > 0)
</span><span class="cx">
</span><span class="cx">
</span><del>- @classmethod
- def allDone(cls):
- d = Deferred()
- cls._allDoneCallback = d.callback
- return d
-
-
</del><span class="cx"> @inlineCallbacks
</span><span class="cx"> def doWork(self):
</span><span class="cx">
</span><span class="lines">@@ -170,8 +196,7 @@
</span><span class="cx"> scheduler = ImplicitScheduler()
</span><span class="cx"> yield scheduler.queuedOrganizerProcessing(self.transaction, scheduleActionFromSQL[self.scheduleAction], home, resource, self.icalendarUid, calendar, self.smartMerge)
</span><span class="cx">
</span><del>- if self._allDoneCallback:
- self._allDoneCallback(None)
</del><ins>+ self._dequeued()
</ins><span class="cx">
</span><span class="cx"> except Exception, e:
</span><span class="cx"> log.debug("ScheduleOrganizerWork - exception ID: {id}, UID: '{uid}', {err}", id=self.workID, uid=self.icalendarUid, err=str(e))
</span><span class="lines">@@ -229,8 +254,11 @@
</span><span class="cx"> icalendarUid=resource.uid(),
</span><span class="cx"> homeResourceID=home.id(),
</span><span class="cx"> resourceID=resource.id(),
</span><del>- changedRids=",".join(changedRids) if changedRids else None,
</del><ins>+
+ # Serialize None as ""
+ changedRids=",".join(map(lambda x: "" if x is None else str(x), changedRids)) if changedRids else None,
</ins><span class="cx"> ))
</span><ins>+ cls._enqueued()
</ins><span class="cx"> yield proposal.whenProposed()
</span><span class="cx"> log.debug("ScheduleReplyWork - enqueued for ID: {id}, UID: {uid}, attendee: {att}", id=proposal.workItem.workID, uid=resource.uid(), att=attendee)
</span><span class="cx">
</span><span class="lines">@@ -257,7 +285,8 @@
</span><span class="cx"> calendar = (yield resource.componentForUser())
</span><span class="cx"> organizer = calendar.validOrganizerForScheduling()
</span><span class="cx">
</span><del>- changedRids = self.changedRids.split(",") if self.changedRids else None
</del><ins>+ # Deserialize "" as None
+ changedRids = map(lambda x: DateTime.parseText(x) if x else None, self.changedRids.split(",")) if self.changedRids else None
</ins><span class="cx">
</span><span class="cx"> log.debug("ScheduleReplyWork - running for ID: {id}, UID: {uid}, attendee: {att}", id=self.workID, uid=calendar.resourceUID(), att=attendee)
</span><span class="cx">
</span><span class="lines">@@ -270,6 +299,8 @@
</span><span class="cx"> response = (yield self.sendToOrganizer(home, "REPLY", itipmsg, attendee, organizer))
</span><span class="cx"> yield self.handleSchedulingResponse(response, calendar, resource, False)
</span><span class="cx">
</span><ins>+ self._dequeued()
+
</ins><span class="cx"> except Exception, e:
</span><span class="cx"> log.debug("ScheduleReplyWork - exception ID: {id}, UID: '{uid}', {err}", id=self.workID, uid=calendar.resourceUID(), err=str(e))
</span><span class="cx"> raise
</span><span class="lines">@@ -306,6 +337,7 @@
</span><span class="cx"> homeResourceID=home.id(),
</span><span class="cx"> icalendarText=calendar.getTextWithTimezones(includeTimezones=not config.EnableTimezonesByReference),
</span><span class="cx"> ))
</span><ins>+ cls._enqueued()
</ins><span class="cx"> yield proposal.whenProposed()
</span><span class="cx"> log.debug("ScheduleReplyCancelWork - enqueued for ID: {id}, UID: {uid}, attendee: {att}", id=proposal.workItem.workID, uid=calendar.resourceUID(), att=attendee)
</span><span class="cx">
</span><span class="lines">@@ -330,6 +362,8 @@
</span><span class="cx"> # Send scheduling message - no need to process response as original resource is gone
</span><span class="cx"> yield self.sendToOrganizer(home, "CANCEL", itipmsg, attendee, organizer)
</span><span class="cx">
</span><ins>+ self._dequeued()
+
</ins><span class="cx"> except Exception, e:
</span><span class="cx"> log.debug("ScheduleReplyCancelWork - exception ID: {id}, UID: '{uid}', {err}", id=self.workID, uid=calendar.resourceUID(), err=str(e))
</span><span class="cx"> raise
</span><span class="lines">@@ -409,6 +443,7 @@
</span><span class="cx"> resourceID=organizer_resource.id(),
</span><span class="cx"> notBefore=notBefore
</span><span class="cx"> ))
</span><ins>+ cls._enqueued()
</ins><span class="cx"> yield proposal.whenProposed()
</span><span class="cx"> log.debug("ScheduleRefreshWork - enqueued for ID: {id}, UID: {uid}, attendees: {att}", id=proposal.workItem.workID, uid=organizer_resource.uid(), att=",".join(attendeesToRefresh))
</span><span class="cx">
</span><span class="lines">@@ -464,9 +499,13 @@
</span><span class="cx"> notBefore=notBefore
</span><span class="cx"> )
</span><span class="cx">
</span><ins>+ self._enqueued()
+
</ins><span class="cx"> # Do refresh
</span><span class="cx"> yield self._doDelayedRefresh(attendeesToProcess)
</span><span class="cx">
</span><ins>+ self._dequeued()
+
</ins><span class="cx"> log.debug("ScheduleRefreshWork - done for ID: {id}, UID: {uid}", id=self.workID, uid=self.icalendarUid)
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -542,6 +581,7 @@
</span><span class="cx"> partstat=partstat,
</span><span class="cx"> notBefore=notBefore,
</span><span class="cx"> ))
</span><ins>+ cls._enqueued()
</ins><span class="cx"> yield proposal.whenProposed()
</span><span class="cx"> log.debug("ScheduleAutoReplyWork - enqueued for ID: {id}, UID: {uid}", id=proposal.workItem.workID, uid=resource.uid())
</span><span class="cx">
</span><span class="lines">@@ -559,6 +599,8 @@
</span><span class="cx"> # Do reply
</span><span class="cx"> yield self._sendAttendeeAutoReply()
</span><span class="cx">
</span><ins>+ self._dequeued()
+
</ins><span class="cx"> log.debug("ScheduleAutoReplyWork - done for ID: {id}, UID: {uid}", id=self.workID, uid=self.icalendarUid)
</span><span class="cx">
</span><span class="cx">
</span></span></pre></div>
<a id="CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcaldavdatastoretesttest_queue_schedulingpy"></a>
<div class="addfile"><h4>Added: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/test/test_queue_scheduling.py (0 => 12468)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/test/test_queue_scheduling.py         (rev 0)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/caldav/datastore/test/test_queue_scheduling.py        2014-01-29 01:45:15 UTC (rev 12468)
</span><span class="lines">@@ -0,0 +1,254 @@
</span><ins>+##
+# Copyright (c) 2014 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from twisted.internet.defer import inlineCallbacks, returnValue
+
+from twext.python.clsprop import classproperty
+from twistedcaldav.config import config
+from txdav.caldav.datastore.scheduling.work import ScheduleWorkMixin
+from txdav.caldav.datastore.test.util import CommonStoreTests
+from txdav.common.datastore.test.util import componentUpdate
+from twistedcaldav.ical import normalize_iCalStr
+
+class BaseQueueSchedulingTests(CommonStoreTests):
+
+ """
+ Test store-based calendar sharing.
+ """
+
+ @inlineCallbacks
+ def setUp(self):
+ yield super(BaseQueueSchedulingTests, self).setUp()
+
+ # Enable the queue and make it fast
+ self.patch(config.Scheduling.Options.WorkQueues, "Enabled", True)
+ self.patch(config.Scheduling.Options.WorkQueues, "RequestDelaySeconds", 1)
+ self.patch(config.Scheduling.Options.WorkQueues, "ReplyDelaySeconds", 1)
+ self.patch(config.Scheduling.Options.WorkQueues, "AutoReplyDelaySeconds", 1)
+ self.patch(config.Scheduling.Options.WorkQueues, "AttendeeRefreshBatchDelaySeconds", 1)
+ self.patch(config.Scheduling.Options.WorkQueues, "AttendeeRefreshBatchIntervalSeconds", 1)
+
+
+ @classproperty(cache=False)
+ def requirements(cls): #@NoSelf
+ return {
+ "user01": {
+ "calendar": {
+ },
+ "inbox": {
+ },
+ },
+ "user02": {
+ "calendar": {
+ },
+ "inbox": {
+ },
+ },
+ "user03": {
+ "calendar": {
+ },
+ "inbox": {
+ },
+ },
+ }
+
+
+ @inlineCallbacks
+ def _getOneResource(self, home, calendar_name):
+ """
+ Get the one resources expected in a collection
+ """
+ inbox = yield self.calendarUnderTest(home=home, name=calendar_name)
+ objs = yield inbox.objectResources()
+ self.assertEqual(len(objs), 1)
+ returnValue(objs[0])
+
+
+ @inlineCallbacks
+ def _testOneResource(self, home, calendar_name, data):
+ """
+ Get the one resources expected in a collection
+ """
+ inbox = yield self.calendarUnderTest(home=home, name=calendar_name)
+ objs = yield inbox.objectResources()
+ self.assertEqual(len(objs), 1)
+
+ caldata = yield objs[0].componentForUser()
+ self.assertEqual(normalize_iCalStr(caldata), normalize_iCalStr(componentUpdate(data)))
+
+
+
+class SimpleSchedulingTests(BaseQueueSchedulingTests):
+
+ @inlineCallbacks
+ def test_invite_reply(self):
+ """
+ Test simple invite/reply roundtrip.
+ """
+
+ data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user01@example.com
+ATTENDEE:mailto:user02@example.com
+DTSTAMP:20051222T210507Z
+ORGANIZER:mailto:user01@example.com
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE;SCHEDULE-STATUS=1.2:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data3 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REQUEST
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data4 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;RSVP=TRUE:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+TRANSP:TRANSPARENT
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data5 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;PARTSTAT=ACCEPTED:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data6 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;PARTSTAT=ACCEPTED;SCHEDULE-STATUS=2.0:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data7 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+METHOD:REPLY
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;PARTSTAT=ACCEPTED:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com:urn:uuid:user01
+SUMMARY:1
+REQUEST-STATUS:2.0;Success
+END:VEVENT
+END:VCALENDAR
+"""
+
+ data8 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890
+DTSTART:{now}T000000Z
+DURATION:PT1H
+ATTENDEE;CN=User 01;EMAIL=user01@example.com;PARTSTAT=ACCEPTED:urn:uuid:user01
+ATTENDEE;CN=User 02;EMAIL=user02@example.com;PARTSTAT=ACCEPTED:urn:uuid:user02
+DTSTAMP:20051222T210507Z
+ORGANIZER;CN=User 01;EMAIL=user01@example.com;SCHEDULE-STATUS=1.2:urn:uuid:user01
+SUMMARY:1
+END:VEVENT
+END:VCALENDAR
+"""
+
+ waitForWork = ScheduleWorkMixin.allDone()
+ calendar = yield self.calendarUnderTest(home="user01", name="calendar")
+ yield calendar.createCalendarObjectWithName("data1.ics", componentUpdate(data1))
+ yield self.commit()
+
+ yield waitForWork
+
+ yield self._testOneResource("user01", "calendar", data2)
+ yield self._testOneResource("user02", "inbox", data3)
+ yield self._testOneResource("user02", "calendar", data4)
+ yield self.commit()
+
+ waitForWork = ScheduleWorkMixin.allDone()
+ cobj = yield self._getOneResource("user02", "calendar")
+ yield cobj.setComponent(componentUpdate(data5))
+ yield self.commit()
+
+ yield waitForWork
+
+ yield self._testOneResource("user01", "calendar", data6)
+ yield self._testOneResource("user01", "inbox", data7)
+ yield self._testOneResource("user02", "calendar", data8)
</ins></span></pre></div>
<a id="CalendarServerbranchesuserscdabooschedulingqueuerefreshtxdavcommondatastoretestutilpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/common/datastore/test/util.py (12467 => 12468)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/common/datastore/test/util.py        2014-01-28 19:56:12 UTC (rev 12467)
+++ CalendarServer/branches/users/cdaboo/scheduling-queue-refresh/txdav/common/datastore/test/util.py        2014-01-29 01:45:15 UTC (rev 12468)
</span><span class="lines">@@ -529,7 +529,7 @@
</span><span class="cx"> return data % {"now": nowYear}
</span><span class="cx">
</span><span class="cx">
</span><del>-dateSubstitutions = {}
</del><ins>+relativeDateSubstitutions = {}
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def componentUpdate(data):
</span><span class="lines">@@ -537,24 +537,24 @@
</span><span class="cx"> Update the supplied iCalendar data so that all dates are updated to the current year.
</span><span class="cx"> """
</span><span class="cx">
</span><del>- if len(dateSubstitutions) == 0:
</del><ins>+ if len(relativeDateSubstitutions) == 0:
</ins><span class="cx"> now = DateTime.getToday()
</span><span class="cx">
</span><del>- dateSubstitutions["now"] = now
</del><ins>+ relativeDateSubstitutions["now"] = now
</ins><span class="cx">
</span><span class="cx"> for i in range(30):
</span><span class="cx"> attrname = "now_back%s" % (i + 1,)
</span><del>- setattr(self, attrname, now.duplicate())
- getattr(self, attrname).offsetDay(-(i + 1))
- dateSubstitutions[attrname] = getattr(self, attrname)
</del><ins>+ dt = now.duplicate()
+ dt.offsetDay(-(i + 1))
+ relativeDateSubstitutions[attrname] = dt
</ins><span class="cx">
</span><span class="cx"> for i in range(30):
</span><span class="cx"> attrname = "now_fwd%s" % (i + 1,)
</span><del>- setattr(self, attrname, now.duplicate())
- getattr(self, attrname).offsetDay(i + 1)
- dateSubstitutions[attrname] = getattr(self, attrname)
</del><ins>+ dt = now.duplicate()
+ dt.offsetDay(i + 1)
+ relativeDateSubstitutions[attrname] = dt
</ins><span class="cx">
</span><del>- return Component.fromString(data.format(dateSubstitutions))
</del><ins>+ return Component.fromString(data.format(**relativeDateSubstitutions))
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>