[CalendarServer-changes] [5556] CalendarServer/branches/users/wsanchez/transations/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Sun May 2 20:44:42 PDT 2010
Revision: 5556
http://trac.macosforge.org/projects/calendarserver/changeset/5556
Author: glyph at apple.com
Date: 2010-05-02 20:44:37 -0700 (Sun, 02 May 2010)
Log Message:
-----------
Correct some terminology and propagate back-end store to the 'calendar' level.
Modified Paths:
--------------
CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.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-02 21:40:09 UTC (rev 5555)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/static.py 2010-05-03 03:44:37 UTC (rev 5556)
@@ -961,7 +961,8 @@
def url(self):
return joinURL(self.parent.url(), self.record.uid)
-class CalendarHomeFile (AutoProvisioningFileMixIn, SharedHomeMixin, DirectoryCalendarHomeResource, CalDAVFile):
+class CalendarHomeFile(AutoProvisioningFileMixIn, SharedHomeMixin,
+ DirectoryCalendarHomeResource, CalDAVFile):
"""
Calendar home collection resource.
"""
@@ -980,9 +981,11 @@
self.clientNotifier = ClientNotifier(self)
CalDAVFile.__init__(self, path)
DirectoryCalendarHomeResource.__init__(self, parent, record)
- self._newStoreCalendar = (self.parent.parent._newStore.newTransaction()
- .calendarHomeWithUID(self.record.uid,
- create=True))
+ self._newStoreCalendarHome = (
+ self.parent.parent._newStore.newTransaction()
+ .calendarHomeWithUID(self.record.uid,
+ create=True)
+ )
def provision(self):
result = super(CalendarHomeFile, self).provision()
@@ -1024,8 +1027,15 @@
if self.comparePath(path):
return self
else:
- similar = CalDAVFile(path, principalCollections=self.principalCollections())
+ similar = CalDAVFile(
+ path, principalCollections=self.principalCollections()
+ )
similar.clientNotifier = self.clientNotifier
+ similar._newStoreCalendar = (
+ self._newStoreCalendarHome.calendarWithName(
+ similar.fp.basename()
+ )
+ )
return similar
def getChild(self, name):
Modified: CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py
===================================================================
--- CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py 2010-05-02 21:40:09 UTC (rev 5555)
+++ CalendarServer/branches/users/wsanchez/transations/twistedcaldav/test/test_wrapping.py 2010-05-03 03:44:37 UTC (rev 5556)
@@ -13,21 +13,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
##
-from twistedcaldav.test.util import TestCase
+
+"""
+Tests for the interaction between model-level and protocol-level logic.
+"""
+
+from twext.python.filepath import CachingFilePath as FilePath
+from twext.web2.dav import davxml
+from twisted.internet.defer import inlineCallbacks, returnValue
from twistedcaldav.config import config
-from twext.python.filepath import CachingFilePath as FilePath
-from twistedcaldav.directory.test.test_xmlfile import xmlFile
+from twistedcaldav.directory import augment
+from twistedcaldav.directory.calendar import uidsResourceName
+from twistedcaldav.directory.principal import \
+ DirectoryPrincipalProvisioningResource
+from twistedcaldav.directory.test.test_xmlfile import augmentsFile, xmlFile
from twistedcaldav.directory.xmlfile import XMLDirectoryService
-from twistedcaldav.directory import augment
-from twistedcaldav.directory.test.test_xmlfile import augmentsFile
-from twistedcaldav.directory.principal import DirectoryPrincipalProvisioningResource
-from twext.web2.dav import davxml
from twistedcaldav.static import CalendarHomeProvisioningFile
-from txcaldav.calendarstore.file import CalendarStore
-from twisted.internet.defer import inlineCallbacks
-from twistedcaldav.directory.calendar import uidsResourceName
+from twistedcaldav.test.util import TestCase
+from txcaldav.calendarstore.file import CalendarStore, CalendarHome
+
class WrappingTests(TestCase):
"""
Tests for L{twistedcaldav.static.CalDAVFile} creating the appropriate type
@@ -62,29 +68,68 @@
self.site.resource.setAccessControlList(davxml.ACL())
+ @inlineCallbacks
+ def getResource(self, path):
+ """
+ Retrieve a resource from the site.
+
+ @param path: the path from the root of the site (not starting with a
+ slash)
+
+ @type path: C{str}
+ """
+ segments = path.split("/")
+ resource = self.site.resource
+ while segments:
+ resource, segments = yield resource.locateChild(None, segments)
+ returnValue(resource)
+
+
def test_createStore(self):
"""
Creating a CalendarHomeProvisioningFile will create a paired
CalendarStore.
"""
self.assertIsInstance(self.calendarCollection._newStore, CalendarStore)
- self.assertEqual(self.calendarCollection._newStore._path,
- self.calendarCollection.fp.child(uidsResourceName))
+ self.assertEquals(self.calendarCollection._newStore._path,
+ self.calendarCollection.fp.child(uidsResourceName))
@inlineCallbacks
+ def test_lookupCalendarHome(self):
+ """
+ When a L{CalDAVFile} representing an existing calendar home is looked up
+ in a CalendarHomeFile, it will create a corresponding L{CalendarHome}
+ via C{newTransaction().calendarHomeWithUID}.
+ """
+ calDavFile = yield self.getResource("calendars/users/wsanchez/")
+ self.assertEquals(calDavFile.fp, calDavFile._newStoreCalendarHome._path)
+ self.assertIsInstance(calDavFile._newStoreCalendarHome, CalendarHome)
+
+
+ @inlineCallbacks
def test_lookupCalendar(self):
"""
- When a L{CalDAVFile} representing an existing calendar collection is
- looked up in a CalendarHomeProvisioningFile, it will create a
- corresponding L{txcaldav.calendarstore.file.Calendar} via
- calendarHomeWithUID.
+ 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}.
"""
- segments = ["users", "wsanchez", ""]
- resource = self.calendarCollection
- while segments:
- resource, segments = yield resource.locateChild(None, segments)
- self.assertEqual(resource.fp, resource._newStoreCalendar._path)
+ calDavFile = yield self.getResource("calendars/users/wsanchez/calendar")
+ self.assertEquals(calDavFile.fp, calDavFile._newStoreCalendar._path)
-
+ @inlineCallbacks
+ def test_lookupSpecial(self):
+ """
+ When a L{CalDAVFile} I{not} representing a calendar collection - one of
+ the special collections, like the dropbox or freebusy URLs - is looked
+ up in a L{CalendarHomeFile} representing a calendar home, it will I{not}
+ create a corresponding L{Calendar} via C{CalendarHome.calendarWithName}.
+ """
+ for specialName in ['dropbox', 'freebusy', 'notifications']:
+ calDavFile = yield self.getResource(
+ "calendars/users/wsanchez/%s" % (specialName,)
+ )
+ self.assertIdentical(
+ getattr(calDavFile, "_newStoreCalendar", None), None
+ )
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100502/87ab8cc3/attachment-0001.html>
More information about the calendarserver-changes
mailing list