def test_connectionLost_clientClose(self):
'''If connectionLost is called because the client closed the
connection, then this connection has disappeared suddenly.
Consequently, the protocol's terminationDeferred errbacks with
the provided reason, the timeout clock is stopped, and the
session machine learns about the lost connection.
'''
erroredDeferred = self.protocol.terminationDeferred
def trapConnectionDone(failure):
failure.trap(error.ConnectionDone)
erroredDeferred.addErrback(trapConnectionDone)
self.protocol.connectionLost(connectionDone)
self.assertEqual(self.timeoutClockRecorder.stopCalls, 1)
self.assertEqual(self.sessionMachineRecorder.connectionsLostReasons,
[connectionDone])
self.assertIsNone(self.protocol.sessionMachine)
return erroredDeferred
评论列表
文章目录