author | Jens Alfke <jens@mooseyard.com> |
Mon Jul 20 13:26:29 2009 -0700 (2009-07-20) | |
changeset 59 | 46c7844cb592 |
parent 53 | e9f209a24d53 |
permissions | -rw-r--r-- |
morrowa@51 | 1 |
# CloseTestPing.py |
morrowa@51 | 2 |
# Tests the closing negotiation facilities of the BLIP 1.1 protocol |
morrowa@51 | 3 |
|
morrowa@51 | 4 |
from BLIP import Connection, OutgoingRequest |
morrowa@51 | 5 |
|
morrowa@51 | 6 |
import unittest |
morrowa@51 | 7 |
import asyncore |
morrowa@51 | 8 |
import logging |
morrowa@51 | 9 |
|
morrowa@51 | 10 |
class CloseTestPing(unittest.TestCase): |
morrowa@51 | 11 |
|
morrowa@51 | 12 |
def handleCloseRefusal(self, resp): |
morrowa@51 | 13 |
logging.info("Close request was refused!") |
morrowa@51 | 14 |
|
morrowa@51 | 15 |
def setUp(self): |
morrowa@51 | 16 |
self.connection = Connection( ('localhost', 1337) ) |
morrowa@51 | 17 |
self.connection.onCloseRefused = self.handleCloseRefusal |
morrowa@51 | 18 |
|
morrowa@51 | 19 |
def handleResponse(self, resp): |
morrowa@51 | 20 |
logging.info("Got response...") |
morrowa@51 | 21 |
|
morrowa@51 | 22 |
def testClose(self): |
morrowa@51 | 23 |
req = OutgoingRequest(self.connection, "Ping") |
morrowa@51 | 24 |
req.response.onComplete = self.handleResponse |
morrowa@51 | 25 |
req.send() |
morrowa@51 | 26 |
|
morrowa@56 | 27 |
asyncore.loop(timeout=0, count=5) # give things time to send |
morrowa@51 | 28 |
|
morrowa@51 | 29 |
self.connection.close() |
morrowa@51 | 30 |
|
morrowa@51 | 31 |
asyncore.loop() |
morrowa@51 | 32 |
|
morrowa@51 | 33 |
|
morrowa@51 | 34 |
if __name__ == '__main__': |
morrowa@56 | 35 |
logging.basicConfig(level=logging.INFO) |
morrowa@51 | 36 |
unittest.main() |