[CalendarServer-changes] [3829] CalendarServer/trunk/twistedcaldav/test/test_memcache.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 11 15:57:24 PDT 2009


Revision: 3829
          http://trac.macosforge.org/projects/calendarserver/changeset/3829
Author:   wsanchez at apple.com
Date:     2009-03-11 15:57:24 -0700 (Wed, 11 Mar 2009)
Log Message:
-----------
Update from Twisted trunk

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/test/test_memcache.py

Modified: CalendarServer/trunk/twistedcaldav/test/test_memcache.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_memcache.py	2009-03-11 22:47:08 UTC (rev 3828)
+++ CalendarServer/trunk/twistedcaldav/test/test_memcache.py	2009-03-11 22:57:24 UTC (rev 3829)
@@ -1,18 +1,20 @@
-# Copyright (c) 2007 Twisted Matrix Laboratories.
+# Copyright (c) 2007-2009 Twisted Matrix Laboratories.
 # See LICENSE for details.
 
 """
 Test the memcache client protocol.
 """
 
-from twistedcaldav.memcache import MemCacheProtocol, NoSuchCommand
-from twistedcaldav.memcache import ClientError, ServerError
+from twisted.protocols.memcache import MemCacheProtocol, NoSuchCommand
+from twisted.protocols.memcache import ClientError, ServerError
 
+from twisted.trial.unittest import TestCase
 from twisted.test.proto_helpers import StringTransportWithDisconnection
 from twisted.internet.task import Clock
 from twisted.internet.defer import Deferred, gatherResults, TimeoutError
-from twistedcaldav.test.util import TestCase
 
+
+
 class MemCacheTestCase(TestCase):
     """
     Test client protocol class L{MemCacheProtocol}.
@@ -23,7 +25,6 @@
         Create a memcache client, connect it to a string protocol, and make it
         use a deterministic clock.
         """
-        TestCase.setUp(self)
         self.proto = MemCacheProtocol()
         self.clock = Clock()
         self.proto.callLater = self.clock.callLater
@@ -31,6 +32,7 @@
         self.transport.protocol = self.proto
         self.proto.makeConnection(self.transport)
 
+
     def _test(self, d, send, recv, result):
         """
         Shortcut method for classic tests.
@@ -189,6 +191,19 @@
             {"foo": "bar", "egg": "spam"})
 
 
+    def test_statsWithArgument(self):
+        """
+
+        L{MemCacheProtocol.stats} takes an optional C{str} argument which,
+        if specified, is sent along with the I{STAT} command.  The I{STAT}
+        responses from the server are parsed as key/value pairs and returned
+        as a C{dict} (as in the case where the argument is not specified).
+        """
+        return self._test(self.proto.stats("blah"), "stats blah\r\n",
+            "STAT foo bar\r\nSTAT egg spam\r\nEND\r\n",
+            {"foo": "bar", "egg": "spam"})
+
+
     def test_version(self):
         """
         Test version retrieval via the L{MemCacheProtocol.version} command: it
@@ -304,7 +319,7 @@
         def check(result):
             self.assertEquals(result, (0, "bar"))
             self.assertEquals(len(self.clock.calls), 1)
-            for _ignore in range(self.proto.persistentTimeOut):
+            for i in range(self.proto.persistentTimeOut):
                 self.clock.advance(1)
             return self.assertFailure(d2, TimeoutError).addCallback(checkTime)
         def checkTime(ignored):
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20090311/8c3217b3/attachment.html>


More information about the calendarserver-changes mailing list