[CalendarServer-changes] [5571] CalendarServer/branches/users/wsanchez/transations/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 6 11:11:03 PDT 2010
Revision: 5571
http://trac.macosforge.org/projects/calendarserver/changeset/5571
Author: glyph at apple.com
Date: 2010-05-06 11:11:00 -0700 (Thu, 06 May 2010)
Log Message:
-----------
Reduce dependencies of index tests, start integrating new store into calendar creation code path. (Work in progress; many tests broken right now)
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_index.py
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py 2010-05-05 15:48:13 UTC (rev 5570)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py 2010-05-06 18:11:00 UTC (rev 5571)
@@ -252,6 +252,9 @@
This will immediately create the collection without performing any
verification. For the normal API, see L{CalDAVFile.createCalendar}.
+
+ @return: a L{Deferred} which fires when the underlying collection has
+ actually been created.
"""
#
# Create the collection once we know it is safe to do so
@@ -264,15 +267,23 @@
d1 = self.bumpSyncToken()
# Calendar is initially transparent to freebusy
- self.writeDeadProperty(caldavxml.ScheduleCalendarTransp(caldavxml.Transparent()))
+ self.writeDeadProperty(
+ caldavxml.ScheduleCalendarTransp(caldavxml.Transparent())
+ )
# Create the index so its ready when the first PUTs come in
d1.addCallback(lambda _: self.index().create())
d1.addCallback(lambda _: status)
return d1
- d = self.createSpecialCollection(davxml.ResourceType.calendar)
- d.addCallback(onCalendarCollection)
+ # d = self.createSpecialCollection(davxml.ResourceType.calendar)
+ d = succeed(responsecode.CREATED)
+ calendarName = self.fp.basename()
+ self._newStoreParentHome.createCalendarWithName(calendarName)
+ self._newStoreCalendar = self._newStoreParentHome.calendarWithName(
+ calendarName
+ )
+ # d.addCallback(onCalendarCollection)
return d
def createSpecialCollection(self, resourceType=None):
@@ -1048,6 +1059,7 @@
path, principalCollections=self.principalCollections()
)
similar.clientNotifier = self.clientNotifier
+ similar._newStoreParentHome = self._newStoreCalendarHome
similar._newStoreCalendar = (
self._newStoreCalendarHome.calendarWithName(
similar.fp.basename()
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_index.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_index.py 2010-05-05 15:48:13 UTC (rev 5570)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_index.py 2010-05-06 18:11:00 UTC (rev 5571)
@@ -28,12 +28,35 @@
from twistedcaldav.query import queryfilter
from twistedcaldav.test.util import InMemoryMemcacheProtocol
import twistedcaldav.test.util
-from vobject.icalendar import utc
-import sqlite3
import datetime
import os
+
+class MinimalResourceReplacement(object):
+ """
+ Provide the minimal set of attributes and methods from CalDAVFile required
+ by L{Index}.
+ """
+
+ def __init__(self, filePath):
+ self.fp = filePath
+
+
+ def isCalendarCollection(self):
+ return True
+
+
+ def getChild(self, name):
+ # FIXME: this should really return something with a child method
+ return self.fp.child(name)
+
+
+ def initSyncToken(self):
+ pass
+
+
+
class SQLIndexTests (twistedcaldav.test.util.TestCase):
"""
Test abstract SQL DB class
@@ -42,7 +65,10 @@
def setUp(self):
super(SQLIndexTests, self).setUp()
self.site.resource.isCalendarCollection = lambda: True
- self.db = Index(self.site.resource)
+ self.indexDirPath = self.site.resource.fp
+ # FIXME: since this resource lies about isCalendarCollection, it doesn't
+ # have all the associated backend machinery to actually get children.
+ self.db = Index(MinimalResourceReplacement(self.indexDirPath))
def test_reserve_uid_ok(self):
@@ -235,7 +261,7 @@
revision += 1
calendar = Component.fromString(calendar_txt)
if ok:
- f = open(os.path.join(self.site.resource.fp.path, name), "w")
+ f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
del f
@@ -409,7 +435,7 @@
revision += 1
calendar = Component.fromString(calendar_txt)
- f = open(os.path.join(self.site.resource.fp.path, name), "w")
+ f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
del f
@@ -808,7 +834,7 @@
revision += 1
calendar = Component.fromString(calendar_txt)
- f = open(os.path.join(self.site.resource.fp.path, name), "w")
+ f = open(os.path.join(self.indexDirPath.path, name), "w")
f.write(calendar_txt)
del f
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py 2010-05-05 15:48:13 UTC (rev 5570)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py 2010-05-06 18:11:00 UTC (rev 5571)
@@ -136,17 +136,32 @@
@inlineCallbacks
- def test_lookupCalendar(self):
+ def test_lookupExistingCalendar(self):
"""
- When a L{CalDAVFile} representing a calendar collection is looked up in
- a L{CalendarHomeFile} representing a calendar home, it will create a
- corresponding L{Calendar} via C{CalendarHome.calendarWithName}.
+ When a L{CalDAVFile} representing an existing calendar collection is
+ looked up in a L{CalendarHomeFile} representing a calendar home, it will
+ create a corresponding L{Calendar} via C{CalendarHome.calendarWithName}.
"""
calDavFile = yield self.getResource("calendars/users/wsanchez/calendar")
self.assertEquals(calDavFile.fp, calDavFile._newStoreCalendar._path)
@inlineCallbacks
+ def test_lookupNewCalendar(self):
+ """
+ When a L{CalDAVFile} which represents a not-yet-created calendar
+ collection is looked up in a L{CalendarHomeFile} representing a calendar
+ home, it will initially have a new storage backend set to C{None}, but
+ when the calendar is created via a protocol action, the backend will be
+ initialized to match.
+ """
+ calDavFile = yield self.getResource("calendars/users/wsanchez/frobozz")
+ self.assertIdentical(calDavFile._newStoreCalendar, None)
+ calDavFile.createCalendarCollection()
+ self.assertEquals(calDavFile.fp, calDavFile._newStoreCalendar._path)
+
+
+ @inlineCallbacks
def test_lookupSpecial(self):
"""
When a L{CalDAVFile} I{not} representing a calendar collection - one of
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100506/a10ff07a/attachment.html>
More information about the calendarserver-changes
mailing list