[CalendarServer-changes] [2341] CalendarServer/branches/propfind-cache/twistedcaldav

source_changes at macosforge.org source_changes at macosforge.org
Thu Apr 24 14:13:16 PDT 2008


Revision: 2341
          http://trac.macosforge.org/projects/calendarserver/changeset/2341
Author:   dreid at apple.com
Date:     2008-04-24 14:13:16 -0700 (Thu, 24 Apr 2008)

Log Message:
-----------
Forgot to add the tests for the updateCTag changes and the cacheNotifier passing.

Modified Paths:
--------------
    CalendarServer/branches/propfind-cache/twistedcaldav/resource.py

Added Paths:
-----------
    CalendarServer/branches/propfind-cache/twistedcaldav/test/test_static.py

Modified: CalendarServer/branches/propfind-cache/twistedcaldav/resource.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/resource.py	2008-04-24 17:59:26 UTC (rev 2340)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/resource.py	2008-04-24 21:13:16 UTC (rev 2341)
@@ -156,7 +156,7 @@
                 d = self.owner(request)
                 d.addCallback(lambda x: davxml.Owner(x))
                 return d
-            
+
         elif namespace == caldav_namespace:
             if name == "supported-calendar-component-set":
                 # CalDAV-access-09, section 5.2.3
@@ -195,7 +195,7 @@
                         responsecode.NOT_IMPLEMENTED,
                         "Component %s is not supported by this server" % (component.toxml(),)
                     ))
-                    
+
         # Strictly speaking CalDAV:timezone is a live property in the sense that the
         # server enforces what can be stored, however it need not actually
         # exist so we cannot list it in liveProperties on this resource, since its
@@ -214,6 +214,14 @@
 
         return super(CalDAVResource, self).writeProperty(property, request)
 
+#     def writeDeadProperty(self, property):
+#         val = super(CalDAVResource, self).writeDeadProperty(property, request)
+
+#         if hasattr(self, 'cacheNotifier'):
+#             self.cacheNotifier.propertyChanged()
+
+#         return val
+
     ##
     # ACL
     ##
@@ -313,7 +321,7 @@
         owner = d.getResult()
         result = (davxml.Principal(owner) == self.currentPrincipal(request))
         yield result
- 
+
     ##
     # CalDAV
     ##
@@ -351,13 +359,13 @@
 
         def checkPrivilegesError(failure):
             failure.trap(AccessDeniedError)
-            
+
             reactor.callLater(0, getChild)
 
         def checkPrivileges(child):
             if privileges is None:
                 return child
-   
+
             ca = child.checkPrivileges(request, privileges)
             ca.addCallback(lambda ign: child)
             return ca
@@ -366,7 +374,7 @@
             if child.isCalendarCollection():
                 callback(child, childpath)
             elif child.isCollection():
-                if depth == "infinity": 
+                if depth == "infinity":
                     fc = child.findCalendarCollections(depth, request, callback, privileges)
                     fc.addCallback(lambda x: reactor.callLater(0, getChild))
                     return fc
@@ -478,10 +486,10 @@
         calendar collection have the same privileges unless explicitly overridden. The same applies
         to drop box collections as we want all resources (attachments) to have the same privileges as
         the drop box collection.
-        
+
         @param newaces: C{list} of L{ACE} for ACL being set.
         """
-        
+
         # Do this only for regular calendar collections and Inbox/Outbox
         if self.isPseudoCalendarCollection():
             edited_aces = []
@@ -494,7 +502,7 @@
                     edited_aces.append(ace)
         else:
             edited_aces = newaces
-        
+
         # Do inherited with possibly modified set of aces
         super(CalDAVResource, self).writeNewACEs(edited_aces)
 
@@ -675,14 +683,14 @@
             def getFreeBusy(has):
                 if not has:
                     return ()
-    
+
                 def parseFreeBusy(freeBusySet):
                     return tuple(str(href) for href in freeBusySet.children)
-        
+
                 d = inbox.readProperty((caldav_namespace, "calendar-free-busy-set"), request)
                 d.addCallback(parseFreeBusy)
                 return d
-    
+
             d = inbox.hasProperty((caldav_namespace, "calendar-free-busy-set"), request)
             d.addCallback(getFreeBusy)
             return d
@@ -710,10 +718,10 @@
         """
         if self.hasDeadProperty((caldav_namespace, "schedule-outbox-URL")):
             outbox = self.readDeadProperty((caldav_namespace, "schedule-outbox-URL"))
-            return str(outbox.children[0])        
+            return str(outbox.children[0])
         else:
             return None
-        
+
     def dropboxURL(self):
         """
         @return: the drop box home collection URL for this principal.
@@ -723,7 +731,7 @@
             return str(inbox.children[0])
         else:
             return None
-        
+
     def notificationsURL(self):
         """
         @return: the notifications collection URL for this principal.

Added: CalendarServer/branches/propfind-cache/twistedcaldav/test/test_static.py
===================================================================
--- CalendarServer/branches/propfind-cache/twistedcaldav/test/test_static.py	                        (rev 0)
+++ CalendarServer/branches/propfind-cache/twistedcaldav/test/test_static.py	2008-04-24 21:13:16 UTC (rev 2341)
@@ -0,0 +1,61 @@
+##
+# Copyright (c) 2008 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.trial.unittest import TestCase
+
+from twistedcaldav.static import CalendarHomeFile, CalDAVFile
+from twistedcaldav.cache import CacheChangeNotifier
+
+
+class StubParentResource(object):
+    def principalCollections(self):
+        return set([])
+
+
+class StubCacheChangeNotifier(object):
+    dataChangedCount = 0
+
+    def dataChanged(self):
+        self.dataChangedCount += 1
+
+
+class CalendarHomeFileTests(TestCase):
+    def setUp(self):
+        self.calendarHome = CalendarHomeFile(self.mktemp(),
+                                             StubParentResource(),
+                                             object())
+
+    def test_hasCacheNotifier(self):
+        self.failUnless(isinstance(self.calendarHome.cacheNotifier,
+                                   CacheChangeNotifier))
+
+    def test_childrenHaveCacheNotifier(self):
+        child = self.calendarHome.createSimilarFile('/fake/path')
+        self.assertEquals(child.cacheNotifier, self.calendarHome.cacheNotifier)
+
+
+class CalDAVFileTests(TestCase):
+    def setUp(self):
+        self.caldavFile = CalDAVFile(self.mktemp())
+        self.caldavFile.fp.createDirectory()
+        self.caldavFile.cacheNotifier = StubCacheChangeNotifier()
+        self.assertEquals(self.caldavFile.cacheNotifier.dataChangedCount, 0)
+        self.caldavFile.isCollection = (lambda: True)
+
+
+    def test_updateCTagNotifiesCache(self):
+        self.caldavFile.updateCTag()
+        self.assertEquals(self.caldavFile.cacheNotifier.dataChangedCount, 1)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20080424/978bd794/attachment.html


More information about the calendarserver-changes mailing list