1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Python/CloseTestPing.py Tue Jun 23 11:44:30 2009 -0700
1.3 @@ -0,0 +1,36 @@
1.4 +# CloseTestPing.py
1.5 +# Tests the closing negotiation facilities of the BLIP 1.1 protocol
1.6 +
1.7 +from BLIP import Connection, OutgoingRequest
1.8 +
1.9 +import unittest
1.10 +import asyncore
1.11 +import logging
1.12 +
1.13 +class CloseTestPing(unittest.TestCase):
1.14 +
1.15 + def handleCloseRefusal(self, resp):
1.16 + logging.info("Close request was refused!")
1.17 +
1.18 + def setUp(self):
1.19 + self.connection = Connection( ('localhost', 1337) )
1.20 + self.connection.onCloseRefused = self.handleCloseRefusal
1.21 +
1.22 + def handleResponse(self, resp):
1.23 + logging.info("Got response...")
1.24 +
1.25 + def testClose(self):
1.26 + req = OutgoingRequest(self.connection, "Ping")
1.27 + req.response.onComplete = self.handleResponse
1.28 + req.send()
1.29 +
1.30 + asyncore.loop(timeout=1, count=5)
1.31 +
1.32 + self.connection.close()
1.33 +
1.34 + asyncore.loop()
1.35 +
1.36 +
1.37 +if __name__ == '__main__':
1.38 + logging.basicConfig(level=logging.DEBUG)
1.39 + unittest.main()