[CalendarServer-changes] [11475] CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/ test_sendfdport.py

source_changes at macosforge.org source_changes at macosforge.org
Fri Jul 5 17:43:07 PDT 2013


Revision: 11475
          http://trac.calendarserver.org//changeset/11475
Author:   glyph at apple.com
Date:     2013-07-05 17:43:07 -0700 (Fri, 05 Jul 2013)
Log Message:
-----------
New test for statusMessage as well.

Modified Paths:
--------------
    CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py

Modified: CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py
===================================================================
--- CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py	2013-07-06 00:43:05 UTC (rev 11474)
+++ CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py	2013-07-06 00:43:07 UTC (rev 11475)
@@ -166,7 +166,7 @@
             def statusFromMessage(self, previous, message):
                 if previous is None:
                     previous = 1
-                return previous + 1
+                return previous - 1
 
             def statusesChanged(self, statuses):
                 q.append(statuses)
@@ -177,6 +177,34 @@
         dispatcher.addSocket()
         dispatcher.sendFileDescriptor(object(), description)
         dispatcher.sendFileDescriptor(object(), description)
-        self.assertEquals(q, [1, 1])
+        self.assertEquals(q, [[1], [2]])
 
 
+    def test_statusesChangedOnStatusMessage(self):
+        """
+        L{InheritedSocketDispatcher.sendFileDescriptor} will update its
+        C{statusWatcher} will update its C{statusWatcher} via
+        C{statusesChanged}.
+        """
+        q = []
+        class Watcher(object):
+            def newConnectionStatus(self, previous):
+                if previous is None:
+                    previous = 0
+                return previous + 1
+
+            def statusFromMessage(self, previous, message):
+                if previous is None:
+                    previous = 1
+                return previous - 1
+
+            def statusesChanged(self, statuses):
+                q.append(statuses)
+        dispatcher = self.dispatcher
+        dispatcher.statusWatcher = Watcher()
+        message = "whatever"
+        # Need to have a socket that will accept the descriptors.
+        dispatcher.addSocket()
+        dispatcher.statusMessage(dispatcher._subprocessSockets[0], message)
+        dispatcher.statusMessage(dispatcher._subprocessSockets[0], message)
+        self.assertEquals(q, [[-1], [-2]])
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130705/9d59d644/attachment.html>


More information about the calendarserver-changes mailing list