[CalendarServer-changes] [14470] CalendarServer/branches/users/sagen/trashcan-4
source_changes at macosforge.org
source_changes at macosforge.org
Tue Feb 24 08:43:24 PST 2015
Revision: 14470
http://trac.calendarserver.org//changeset/14470
Author: sagen at apple.com
Date: 2015-02-24 08:43:24 -0800 (Tue, 24 Feb 2015)
Log Message:
-----------
Checkpoint
Modified Paths:
--------------
CalendarServer/branches/users/sagen/trashcan-4/calendarserver/tools/cmdline.py
CalendarServer/branches/users/sagen/trashcan-4/twistedcaldav/stdconfig.py
CalendarServer/branches/users/sagen/trashcan-4/txdav/common/datastore/test/test_sql.py
Modified: CalendarServer/branches/users/sagen/trashcan-4/calendarserver/tools/cmdline.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-4/calendarserver/tools/cmdline.py 2015-02-24 01:10:35 UTC (rev 14469)
+++ CalendarServer/branches/users/sagen/trashcan-4/calendarserver/tools/cmdline.py 2015-02-24 16:43:24 UTC (rev 14470)
@@ -26,6 +26,8 @@
from twistedcaldav.config import ConfigurationError
from twisted.internet.defer import inlineCallbacks, succeed
from twisted.application.service import Service
+from twisted.python.logfile import LogFile
+from twisted.python.log import FileLogObserver
import sys
from calendarserver.tap.util import getRootResource
@@ -94,6 +96,15 @@
if patchConfig is not None:
patchConfig(config)
+ utilityLogFile = LogFile.fromFullPath(
+ config.UtilityLogFile,
+ rotateLength=config.ErrorLogRotateMB * 1024 * 1024,
+ maxRotatedFiles=config.ErrorLogMaxRotatedFiles
+ )
+ utilityLogObserver = FileLogObserver(utilityLogFile)
+ utilityLogObserver.start()
+
+
checkDirectories(config)
config.ProcessType = "Utility"
Modified: CalendarServer/branches/users/sagen/trashcan-4/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-4/twistedcaldav/stdconfig.py 2015-02-24 01:10:35 UTC (rev 14469)
+++ CalendarServer/branches/users/sagen/trashcan-4/twistedcaldav/stdconfig.py 2015-02-24 16:43:24 UTC (rev 14470)
@@ -17,9 +17,11 @@
import copy
import os
+from os.path import basename
from plistlib import PlistParser # @UnresolvedImport
import re
from socket import getfqdn, gethostbyname
+import sys
from calendarserver.push.util import getAPNTopicFromCertificate
from twext.python.log import Logger, InvalidLogLevelError, LogLevel
@@ -386,6 +388,7 @@
"AccessLogFile" : "access.log", # Apache-style access log
"ErrorLogFile" : "error.log", # Server activity log
"AgentLogFile" : "agent.log", # Agent activity log
+ "UtilityLogFile" : "{}.log".format(basename(sys.argv[0])), # Command line utility log
"ErrorLogEnabled" : True, # True = use log file, False = stdout
"ErrorLogRotateMB" : 10, # Rotate error log after so many megabytes
"ErrorLogMaxRotatedFiles" : 5, # Retain this many error log files
@@ -1190,6 +1193,7 @@
("LogRoot", "AccessLogFile"),
("LogRoot", "ErrorLogFile"),
("LogRoot", "AgentLogFile"),
+ ("LogRoot", "UtilityLogFile"),
("LogRoot", ("Postgres", "LogFile",)),
("LogRoot", ("LogDatabase", "StatisticsLogFile",)),
("LogRoot", "AccountingLogRoot"),
Modified: CalendarServer/branches/users/sagen/trashcan-4/txdav/common/datastore/test/test_sql.py
===================================================================
--- CalendarServer/branches/users/sagen/trashcan-4/txdav/common/datastore/test/test_sql.py 2015-02-24 01:10:35 UTC (rev 14469)
+++ CalendarServer/branches/users/sagen/trashcan-4/txdav/common/datastore/test/test_sql.py 2015-02-24 16:43:24 UTC (rev 14470)
@@ -1332,3 +1332,163 @@
self.assertTrue("PARTSTAT=NEEDS-ACTION" in data)
yield txn.commit()
+
+
+ @inlineCallbacks
+ def test_trashScheduledSpanningNowAttendeeRemove(self):
+
+ from twistedcaldav.stdconfig import config
+ self.patch(config, "EnableTrashCollection", True)
+
+ # A month in the past
+ start = DateTime.getNowUTC()
+ start.setHHMMSS(0, 0, 0)
+ start.offsetMonth(-1)
+ end = DateTime.getNowUTC()
+ end.setHHMMSS(1, 0, 0)
+ end.offsetMonth(-1)
+ subs = {
+ "start": start,
+ "end": end,
+ }
+
+ data1 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+""" % subs
+
+ data2 = """BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN
+BEGIN:VEVENT
+UID:12345-67890-attendee-reply
+DTSTART;TZID=America/Los_Angeles:%(start)s
+DTEND;TZID=America/Los_Angeles:%(end)s
+DTSTAMP:20150204T192546Z
+RRULE:FREQ=WEEKLY;COUNT=20
+SUMMARY:Scheduled
+ORGANIZER;CN="User 01":mailto:user01 at example.com
+ATTENDEE:mailto:user01 at example.com
+ATTENDEE;PARTSTAT=ACCEPTED:mailto:user02 at example.com
+END:VEVENT
+END:VCALENDAR
+""" % subs
+
+ # user01 invites user02
+ txn = self.store.newTransaction()
+ yield self._createResource(
+ txn, "user01", "calendar", "test.ics", data1
+ )
+ yield txn.commit()
+
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # user01's copy has SCHEDULE-STATUS update
+ txn = self.store.newTransaction()
+ data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
+ self.assertTrue("SCHEDULE-STATUS=1.2" in data)
+
+ # user02 has an inbox item
+ resourceNames = yield self._getResourceNames(txn, "user02", "inbox")
+ self.assertEqual(len(resourceNames), 1)
+
+ # user02 accepts
+ yield self._updateResource(txn, "user02", "calendar", "", data2)
+ yield txn.commit()
+
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # user01 has an inbox item
+ txn = self.store.newTransaction()
+ resourceNames = yield self._getResourceNames(txn, "user01", "inbox")
+ self.assertEqual(len(resourceNames), 1)
+
+ # user01's copy has SCHEDULE-STATUS update
+ data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
+ self.assertTrue("SCHEDULE-STATUS=2.0" in data)
+ self.assertTrue("PARTSTAT=ACCEPTED" in data)
+ resource = yield self._getResource(txn, "user02", "inbox", "")
+ yield resource.remove()
+
+ yield txn.commit()
+
+ # user02 trashes event
+ txn = self.store.newTransaction()
+ resource = yield self._getResource(txn, "user02", "calendar", "")
+ yield resource.remove()
+ yield txn.commit()
+
+ yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # user01's copy shows user02 declined
+ txn = self.store.newTransaction()
+ data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
+ self.assertTrue("PARTSTAT=DECLINED" in data)
+ yield txn.commit()
+
+ # # user02's copy is cancelled
+ # txn = self.store.newTransaction()
+ # data = yield self._getResourceData(txn, "user02", "inbox", "")
+ # self.assertTrue("METHOD:CANCEL" in data)
+ # resource = yield self._getResource(txn, "user02", "inbox", "")
+ # yield resource.remove()
+ # data = yield self._getResourceData(txn, "user02", "calendar", "")
+ # self.assertTrue("STATUS:CANCELLED" in data)
+ # resource = yield self._getResource(txn, "user02", "calendar", "")
+ # yield resource.remove()
+ # data = yield self._getResource(txn, "user02", "trash", "")
+ # self.assertEquals(data, None)
+ # yield txn.commit()
+
+ # # user01 restores event from the trash
+ # txn = self.store.newTransaction()
+ # resource = yield self._getResource(txn, "user01", "trash", "")
+ # yield resource.fromTrash()
+ # yield txn.commit()
+
+ # yield JobItem.waitEmpty(self.store.newTransaction, reactor, 60)
+
+ # txn = self.store.newTransaction()
+
+ # # user01's trash should be empty
+ # resourceNames = yield self._getResourceNames(txn, "user01", "trash")
+ # self.assertEquals(len(resourceNames), 0)
+
+ # # user01 should have test.ics and a new .ics
+ # resourceNames = yield self._getResourceNames(txn, "user01", "calendar")
+ # self.assertEquals(len(resourceNames), 2)
+ # self.assertTrue("test.ics" in resourceNames)
+ # resourceNames.remove("test.ics")
+ # newName = resourceNames[0]
+
+ # # user01's test.ics -- verify it got split correctly
+ # data = yield self._getResourceData(txn, "user01", "calendar", "test.ics")
+ # self.assertTrue("COUNT=15" in data)
+
+ # # user01's new .ics -- verify it got split correctly
+ # data = yield self._getResourceData(txn, "user01", "calendar", newName)
+ # self.assertTrue("RRULE:FREQ=WEEKLY;UNTIL=" in data)
+
+ # # user02's copy should be back on their calendar, and not in trash
+
+ # resourceNames = yield self._getResourceNames(txn, "user02", "calendar")
+ # self.assertEquals(len(resourceNames), 1)
+ # resourceNames = yield self._getResourceNames(txn, "user02", "trash")
+ # self.assertEquals(len(resourceNames), 0)
+
+ # data = yield self._getResourceData(txn, "user02", "calendar", "")
+ # self.assertTrue("PARTSTAT=NEEDS-ACTION" in data)
+
+ # yield txn.commit()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20150224/2fb356b3/attachment-0001.html>
More information about the calendarserver-changes
mailing list