[CalendarServer-changes] [5696] CalendarServer/branches/new-store/txcaldav/calendarstore/test/common .py

source_changes at macosforge.org source_changes at macosforge.org
Mon Jun 7 12:46:33 PDT 2010


Revision: 5696
          http://trac.macosforge.org/projects/calendarserver/changeset/5696
Author:   glyph at apple.com
Date:     2010-06-07 12:46:31 -0700 (Mon, 07 Jun 2010)
Log Message:
-----------
setComponent wasn't preserving properties; here's a handy test for that.

Modified Paths:
--------------
    CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py

Modified: CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py
===================================================================
--- CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py	2010-06-07 19:31:11 UTC (rev 5695)
+++ CalendarServer/branches/new-store/txcaldav/calendarstore/test/common.py	2010-06-07 19:46:31 UTC (rev 5696)
@@ -33,6 +33,7 @@
 
 from twext.python.filepath import CachingFilePath as FilePath
 from twext.web2.dav import davxml
+from twext.web2.dav.element.base import WebDAVUnknownElement
 from twext.python.vcomponent import VComponent
 
 
@@ -751,6 +752,49 @@
 
     def test_calendarObjectProperties(self):
         """
-        L{ICalendarObject.properties} returns a proprety store.
+        L{ICalendarObject.properties} returns a property store.
         """
         self.checkPropertiesMethod(self.calendarObjectUnderTest())
+
+
+    def test_setComponentPreservesProperties(self):
+        """
+        L{ICalendarObject.setComponent} preserves properties.
+
+        (Some implementations must go to extra trouble to provide this
+        behavior; for example, file storage must copy extended attributes from
+        the existing file to the temporary file replacing it.)
+        """
+        propertyName = PropertyName("http://example.com/ns", "example")
+        propertyContent = WebDAVUnknownElement("sample content")
+        propertyContent.name = propertyName.name
+        propertyContent.namespace = propertyName.namespace
+        
+        self.calendarObjectUnderTest().properties()[
+            propertyName] = propertyContent
+        self.commit()
+        # Sanity check; are properties even readable in a separate transaction?
+        # Should probably be a separate test.
+        self.assertEquals(
+            self.calendarObjectUnderTest().properties()[propertyName],
+            propertyContent)
+        obj = self.calendarObjectUnderTest()
+        event1_text = obj.iCalendarText()
+        event1_text_withDifferentSubject = event1_text.replace(
+            "SUMMARY:CalDAV protocol updates",
+            "SUMMARY:Changed"
+        )
+        # Sanity check; make sure the test has the right idea of the subject.
+        self.assertNotEquals(event1_text, event1_text_withDifferentSubject)
+        newComponent = VComponent.fromString(event1_text_withDifferentSubject)
+        obj.setComponent(newComponent)
+
+        # Putting everything into a separate transaction to account for any
+        # caching that may take place.
+        self.commit()
+        self.assertEquals(
+            self.calendarObjectUnderTest().properties()[propertyName],
+            propertyContent)
+
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100607/0ac65f5d/attachment-0001.html>


More information about the calendarserver-changes mailing list