Example #1
0
class TestMessageInThread(unittest.TestCase):
    """Simple threaded-handler test"""

    def setUp(self):
        unittest.TestCase.setUp(self)
        self.server = ServerHelper()
        self.sock = socket.socket()
        self.sock.connect(("", 44444))
        self.conn = pjs.connection.Connection(self.sock, None, self.server)
        self.server.conns[self.conn.id] = ()
        self.threadpool = pjs.threadpool.ThreadPool(1)

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.conn.handle_close()
        self.server.handle_close()
        self.threadpool.dismissWorkers(1)
        del self.threadpool

    def testSimpleHandler(self):
        h = SimpleThreadedHandler(self.threadpool)

        msg = pjs.events.Message(None, self.conn, [h], None, None)
        msg.process()

        self.threadpool.wait()
        time.sleep(0.5)

        self.assert_(h.passed)
Example #2
0
class TestMessageInThread(unittest.TestCase):
    """Simple threaded-handler test"""
    def setUp(self):
        unittest.TestCase.setUp(self)
        self.server = ServerHelper()
        self.sock = socket.socket()
        self.sock.connect(('', 44444))
        self.conn = pjs.connection.Connection(self.sock, None, self.server)
        self.server.conns[self.conn.id] = ()
        self.threadpool = pjs.threadpool.ThreadPool(1)

    def tearDown(self):
        unittest.TestCase.tearDown(self)
        self.conn.handle_close()
        self.server.handle_close()
        self.threadpool.dismissWorkers(1)
        del self.threadpool

    def testSimpleHandler(self):
        h = SimpleThreadedHandler(self.threadpool)

        msg = pjs.events.Message(None, self.conn, [h], None, None)
        msg.process()

        self.threadpool.wait()
        time.sleep(0.5)

        self.assert_(h.passed)
Example #3
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.server = ServerHelper()
     self.sock = socket.socket()
     self.sock.connect(('', 44444))
     self.conn = pjs.connection.Connection(self.sock, None, self.server)
     self.server.conns[self.conn.id] = ()
     self.threadpool = pjs.threadpool.ThreadPool(1)
Example #4
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.server = ServerHelper()
     self.sock = socket.socket()
     self.sock.connect(("", 44444))
     self.conn = pjs.connection.Connection(self.sock, None, self.server)
     self.server.conns[self.conn.id] = ()
     self.threadpool = pjs.threadpool.ThreadPool(1)