diff -r 000000000000 -r de59ce19f42e Python/CloseTestPing.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Python/CloseTestPing.py Tue Jun 23 11:44:30 2009 -0700 @@ -0,0 +1,36 @@ +# CloseTestPing.py +# Tests the closing negotiation facilities of the BLIP 1.1 protocol + +from BLIP import Connection, OutgoingRequest + +import unittest +import asyncore +import logging + +class CloseTestPing(unittest.TestCase): + + def handleCloseRefusal(self, resp): + logging.info("Close request was refused!") + + def setUp(self): + self.connection = Connection( ('localhost', 1337) ) + self.connection.onCloseRefused = self.handleCloseRefusal + + def handleResponse(self, resp): + logging.info("Got response...") + + def testClose(self): + req = OutgoingRequest(self.connection, "Ping") + req.response.onComplete = self.handleResponse + req.send() + + asyncore.loop(timeout=1, count=5) + + self.connection.close() + + asyncore.loop() + + +if __name__ == '__main__': + logging.basicConfig(level=logging.DEBUG) + unittest.main()