[CalendarServer-changes] [5378] CalendarServer/trunk/txdav/propertystore/test/test_xattr.py
source_changes at macosforge.org
source_changes at macosforge.org
Mon Mar 22 16:42:16 PDT 2010
Revision: 5378
http://trac.macosforge.org/projects/calendarserver/changeset/5378
Author: wsanchez at apple.com
Date: 2010-03-22 16:42:15 -0700 (Mon, 22 Mar 2010)
Log Message:
-----------
Implement tests marked todo
Modified Paths:
--------------
CalendarServer/trunk/txdav/propertystore/test/test_xattr.py
Modified: CalendarServer/trunk/txdav/propertystore/test/test_xattr.py
===================================================================
--- CalendarServer/trunk/txdav/propertystore/test/test_xattr.py 2010-03-22 23:41:50 UTC (rev 5377)
+++ CalendarServer/trunk/txdav/propertystore/test/test_xattr.py 2010-03-22 23:42:15 UTC (rev 5378)
@@ -20,33 +20,80 @@
from zope.interface.verify import verifyObject, BrokenMethodImplementation
-#from twext.python.filepath import CachingFilePath as FilePath
from twisted.trial import unittest
+from twext.python.filepath import FilePath
+from twext.web2.dav import davxml
+
from txdav.idav import IPropertyStore
-from txdav.propertystore.xattr import PropertyStore
+try:
+ from txdav.propertystore.xattr import PropertyStore, PropertyName
+ from xattr import xattr
+except ImportError, e:
+ PropertyStore = None
+ importErrorMessage = str(e)
+
class PropertyStoreTest(unittest.TestCase):
+ def setUp(self):
+ tempDir = FilePath(self.mktemp())
+ tempDir.makedirs()
+ tempFile = tempDir.child("test")
+ tempFile.touch()
+ self.propertyStore = PropertyStore(tempFile)
+
def test_interface(self):
- raise NotImplementedError()
-
- store = PropertyStore()
-
try:
- verifyObject(IPropertyStore, store)
+ verifyObject(IPropertyStore, self.propertyStore)
except BrokenMethodImplementation, e:
self.fail(e)
- test_interface.todo = "Unimplemented"
def test_init(self):
- raise NotImplementedError()
- test_init.todo = "Unimplemented"
+ store = self.propertyStore
+ self.failUnless(isinstance(store.attrs, xattr))
+ self.assertEquals(store.removed, set())
+ self.assertEquals(store.modified, {})
def test_flush(self):
- raise NotImplementedError()
- test_flush.todo = "Unimplemented"
+ store = self.propertyStore
+ name = propertyName("test")
+ value = davxml.ResponseDescription("Hello, World!")
+
+ store[name] = value
+
+ store.flush()
+ store.abort()
+
+ self.assertEquals(store.get(name, None), value)
+
+ del store[name]
+
+ store.flush()
+ store.abort()
+
+ self.assertEquals(store.get(name, None), None)
+
+
def test_abort(self):
- raise NotImplementedError()
- test_abort.todo = "Unimplemented"
+ store = self.propertyStore
+
+ name = propertyName("test")
+ value = davxml.ResponseDescription("Hello, World!")
+
+ store[name] = value
+
+ store.abort()
+
+ self.assertEquals(store.get(name, None), None)
+ self.assertEquals(store.removed, set())
+ self.assertEquals(store.modified, {})
+
+
+if PropertyStore is None:
+ PropertyStoreTest.skip = importErrorMessage
+
+
+def propertyName(name):
+ return PropertyName("http://calendarserver.org/ns/test/", name)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20100322/38d3d693/attachment.html>
More information about the calendarserver-changes
mailing list