[CalendarServer-changes] [11967] CalendarServer/trunk/twext/who/test

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 12 11:18:32 PDT 2014


Revision: 11967
          http://trac.calendarserver.org//changeset/11967
Author:   wsanchez at apple.com
Date:     2013-11-18 21:41:48 -0800 (Mon, 18 Nov 2013)
Log Message:
-----------
More tests

Modified Paths:
--------------
    CalendarServer/trunk/twext/who/test/test_aggregate.py
    CalendarServer/trunk/twext/who/test/test_index.py
    CalendarServer/trunk/twext/who/test/test_xml.py

Modified: CalendarServer/trunk/twext/who/test/test_aggregate.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_aggregate.py	2013-11-19 05:02:42 UTC (rev 11966)
+++ CalendarServer/trunk/twext/who/test/test_aggregate.py	2013-11-19 05:41:48 UTC (rev 11967)
@@ -24,7 +24,6 @@
 from twext.who.idirectory import IDirectoryService, DirectoryConfigurationError
 from twext.who.aggregate import DirectoryService, DirectoryRecord
 from twext.who.util import ConstantsContainer
-
 from twext.who.test import test_directory, test_xml
 from twext.who.test.test_xml import QueryMixIn, xmlService
 from twext.who.test.test_xml import TestService as XMLTestService

Modified: CalendarServer/trunk/twext/who/test/test_index.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_index.py	2013-11-19 05:02:42 UTC (rev 11966)
+++ CalendarServer/trunk/twext/who/test/test_index.py	2013-11-19 05:41:48 UTC (rev 11967)
@@ -20,8 +20,7 @@
 
 from twisted.trial import unittest
 
-from twext.who.directory import DirectoryService, DirectoryRecord
-
+from twext.who.index import DirectoryService, DirectoryRecord
 from twext.who.test import test_directory
 
 
@@ -41,13 +40,59 @@
     directoryRecordClass = DirectoryRecord
 
 
+    def test_init_noIndex(self):
+        """
+        Index starts as C{None}.
+        """
+        service = self.service()
+        self.assertIdentical(service._index, None)
 
+
+    def test_index_get(self):
+        """
+        Getting the C{index} property calls C{loadRecords} and returns the
+        index set by C{loadRecords}.
+        """
+        class TestService(DirectoryService):
+            def loadRecords(self):
+                self.index = self.indexToLoad
+
+        service = TestService("")
+
+        for index in ({}, {}, {}):
+            service.indexToLoad = index
+            self.assertIdentical(service.index, index)
+
+
+    def test_index_set(self):
+        """
+        Setting the index and getting it gives us back the same value.
+        """
+        class TestService(DirectoryService):
+            def loadRecords(self):
+                pass
+
+        service = TestService("")
+
+        for index in ({}, {}, {}):
+            service.index = index
+            self.assertIdentical(service.index, index)
+
+
+    def test_flush(self):
+        """
+        C{flush} sets the index to C{None}.
+        """
+        service = self.service()
+        service._index = {}
+        service.flush()
+        self.assertIdentical(service._index, None)
+
+
     def _noop(self):
         """
-        Does nothing for this class.
+        Does nothing.
         """
-        if self.__class__ is not DirectoryServiceTest:
-            raise NotImplementedError("Subclasses should implement this test.")
 
 
     test_recordWithUID = _noop

Modified: CalendarServer/trunk/twext/who/test/test_xml.py
===================================================================
--- CalendarServer/trunk/twext/who/test/test_xml.py	2013-11-19 05:02:42 UTC (rev 11966)
+++ CalendarServer/trunk/twext/who/test/test_xml.py	2013-11-19 05:41:48 UTC (rev 11967)
@@ -31,7 +31,6 @@
 from twext.who.expression import MatchExpression, MatchType, MatchFlags
 from twext.who.xml import ParseError
 from twext.who.xml import DirectoryService, DirectoryRecord
-
 from twext.who.test import test_index
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20140312/f383a211/attachment.html>


More information about the calendarserver-changes mailing list