[CalendarServer-changes] [11473] 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:04 PDT 2013
Revision: 11473
http://trac.calendarserver.org//changeset/11473
Author: glyph at apple.com
Date: 2013-07-05 17:43:04 -0700 (Fri, 05 Jul 2013)
Log Message:
-----------
Failing test for new idiom to react to status changes. (First direct test for this implied interface.)
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:02 UTC (rev 11472)
+++ CalendarServer/branches/users/glyph/hang-fix/twext/internet/test/test_sendfdport.py 2013-07-06 00:43:04 UTC (rev 11473)
@@ -96,8 +96,8 @@
def test_sendFileDescriptorSorting(self):
"""
- Make sure InheritedSocketDispatcher.sendFileDescriptor sorts sockets with status None
- higher than those with int status values.
+ Make sure InheritedSocketDispatcher.sendFileDescriptor sorts sockets
+ with status None higher than those with int status values.
"""
self.patch(_SubprocessSocket, 'sendSocketToPeer', lambda x, y, z:None)
@@ -125,7 +125,8 @@
self.assertEqual(sockets[1].status, 1)
self.assertEqual(sockets[2].status, 1)
- # Check that after going to 1 and back to 0 that is still preferred over None
+ # Check that after going to 1 and back to 0 that is still preferred
+ # over None
sockets[0].status = 0
sockets[1].status = 1
sockets[2].status = None
@@ -143,3 +144,38 @@
self.assertEqual(sockets[0].status, 1)
self.assertEqual(sockets[1].status, 1)
self.assertEqual(sockets[2].status, None)
+
+
+ def test_statusChangedOnNewConnection(self):
+ """
+ L{InheritedSocketDispatcher.sendFileDescriptor} will update its
+ C{statusWatcher} via C{statusChanged}.
+ """
+ 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 = InheritedSocketDispatcher(Watcher())
+ class Reactish(object):
+ def addReader(self, reader):
+ pass
+ def addWriter(self, writer):
+ pass
+ dispatcher.reactor = Reactish()
+ description = "whatever"
+ # Need to have a socket that will accept the descriptors.
+ dispatcher.addSocket()
+ dispatcher.sendFileDescriptor(object(), description)
+ dispatcher.sendFileDescriptor(object(), description)
+ self.assertEquals(q, [1, 1])
+
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130705/f2910ffc/attachment.html>
More information about the calendarserver-changes
mailing list