[CalendarServer-changes] [10060] CalendarServer/branches/users/glyph/one-home-list-api

source_changes at macosforge.org source_changes at macosforge.org
Fri Nov 16 14:48:58 PST 2012


Revision: 10060
          http://trac.calendarserver.org//changeset/10060
Author:   glyph at apple.com
Date:     2012-11-16 14:48:58 -0800 (Fri, 16 Nov 2012)
Log Message:
-----------
Passing test for existing implementation of `UIDsFolder.list`.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/one-home-list-api/calendarserver/tools/shell/test/test_vfs.py

Property Changed:
----------------
    CalendarServer/branches/users/glyph/one-home-list-api/

Modified: CalendarServer/branches/users/glyph/one-home-list-api/calendarserver/tools/shell/test/test_vfs.py
===================================================================
--- CalendarServer/branches/users/glyph/one-home-list-api/calendarserver/tools/shell/test/test_vfs.py	2012-11-16 22:48:57 UTC (rev 10059)
+++ CalendarServer/branches/users/glyph/one-home-list-api/calendarserver/tools/shell/test/test_vfs.py	2012-11-16 22:48:58 UTC (rev 10060)
@@ -15,14 +15,18 @@
 # limitations under the License.
 ##
 
-import twisted.trial.unittest 
-from twisted.internet.defer import succeed
+from twisted.trial.unittest import TestCase
+from twisted.internet.defer import succeed, inlineCallbacks
 
 from calendarserver.tools.shell.vfs import ListEntry
 from calendarserver.tools.shell.vfs import File, Folder
+from calendarserver.tools.shell.vfs import UIDsFolder
+from calendarserver.tools.shell.terminal import ShellService
+from twistedcaldav.directory.test.test_xmlfile import XMLFileBase
+from txdav.common.datastore.test.util import buildStore
 
 
-class TestListEntry(twisted.trial.unittest.TestCase):
+class TestListEntry(TestCase):
     def test_toString(self):
         self.assertEquals(ListEntry(None, File  , "thingo"           ).toString(), "thingo" )
         self.assertEquals(ListEntry(None, File  , "thingo", Foo="foo").toString(), "thingo" )
@@ -100,3 +104,63 @@
             def list(self): return succeed(())
             list.fieldNames = ()
         self.assertEquals(fields(MyFile), ("thingo",))
+
+
+
+class DirectoryStubber(XMLFileBase):
+    """
+    Object which creates a stub L{IDirectoryService}.
+    """
+    def __init__(self, testCase):
+        self.testCase = testCase
+
+    def mktemp(self):
+        return self.testCase.mktemp()
+
+
+
+class UIDsFolderTests(TestCase):
+    """
+    L{UIDsFolder} contains all principals and is keyed by UID.
+    """
+
+    @inlineCallbacks
+    def setUp(self):
+        """
+        Create a L{UIDsFolder}.
+        """
+        x = None
+        store = yield buildStore(self, None)
+        directory = DirectoryStubber(self).service()
+        options = x
+        reactor = x
+        config = x
+
+        self.svc = ShellService(store, directory, options, reactor, config)
+        self.folder = UIDsFolder(self.svc, ())
+
+
+    @inlineCallbacks
+    def test_list(self):
+        """
+        L{UIDsFolder.list} returns a L{Deferred} firing an iterable of
+        L{ListEntry} objects, reflecting the directory information for all
+        calendars and addressbooks created in the store.
+        """
+        txn = self.svc.store.newTransaction()
+        wsanchez = "6423F94A-6B76-4A3A-815B-D52CFD77935D"
+        dreid = "5FF60DAD-0BDE-4508-8C77-15F0CA5C8DD1"
+        yield txn.calendarHomeWithUID(wsanchez, create=True)
+        yield txn.addressbookHomeWithUID(dreid, create=True)
+        yield txn.commit()
+        listing = list((yield self.folder.list()))
+        self.assertEquals(
+            [x.fields for x in listing],
+            [{"Record Type": "users", "Short Name": "wsanchez",
+              "Full Name": "Wilfredo Sanchez", "Name": wsanchez},
+              {"Record Type": "users", "Short Name": "dreid",
+              "Full Name": "David Reid", "Name": dreid}]
+        )
+
+
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20121116/4602afe5/attachment-0001.html>


More information about the calendarserver-changes mailing list