def test_outPort(self): eventToSend = ["foo"] server = threading.Thread(target=OutPortTest.serverHelper, args=(self, pickle.dumps(eventToSend))) server.setDaemon(False) server.start() outPort = OutPort(OutPortTest.UNIX_SOCKET_ADDR) outPort.connect() outPort.send(eventToSend) server.join()
def test_manyEvents(self): inPort = InPort(InPortTest.UNIX_SOCKET_ADDR) inPort.listen() outPort = OutPort(InPortTest.UNIX_SOCKET_ADDR) outPort.connect() eventsToSent = range(1000) for event in eventsToSent: outPort.send(event) for event in eventsToSent: eventReceived = inPort.receive(1.0) self.assertEqual(event, eventReceived) inPort.dispose()
def test_simple(self): inPort = InPort(InPortTest.UNIX_SOCKET_ADDR) inPort.listen() outPort = OutPort(InPortTest.UNIX_SOCKET_ADDR) outPort.connect() eventsToSent = ["one", "two", 3, 4.0, u"five"] for event in eventsToSent: outPort.send(event) for event in eventsToSent: eventReceived = inPort.receive(1.0) self.assertEqual(event, eventReceived) inPort.dispose()
def test_inOutPort_basic(self): inPort = InPort(PortTest.UNIX_FIRST_ADDR) inOutPort = Port(PortTest.UNIX_FIRST_ADDR, PortTest.UNIX_SECOND_ADDR) outPort = OutPort(PortTest.UNIX_SECOND_ADDR) inPort.listen() inOutPort.initialize() outPort.connect() event = "foo" outPort.send(event) self.assertEqual(event, inOutPort.receive(1.0)) event2 = "bar" inOutPort.send(event2) self.assertEqual(event2, inPort.receive(1.0)) inPort.dispose() inOutPort.dispose()
def test_outPort(self): eventToSend = ['foo'] server = threading.Thread(target=OutPortTest.serverHelper, args=(self, pickle.dumps(eventToSend))) server.setDaemon(False) server.start() outPort = OutPort(OutPortTest.UNIX_SOCKET_ADDR) outPort.connect() outPort.send(eventToSend) server.join()
def test_simple(self): inPort = InPort(InPortTest.UNIX_SOCKET_ADDR) inPort.listen() outPort = OutPort(InPortTest.UNIX_SOCKET_ADDR) outPort.connect() eventsToSent = ['one', 'two', 3, 4.0, u'five'] for event in eventsToSent: outPort.send(event) for event in eventsToSent: eventReceived = inPort.receive(1.0) self.assertEqual(event, eventReceived) inPort.dispose()
def test_inOutPort_basic(self): inPort = InPort(PortTest.UNIX_FIRST_ADDR) inOutPort = Port(PortTest.UNIX_FIRST_ADDR, PortTest.UNIX_SECOND_ADDR) outPort = OutPort(PortTest.UNIX_SECOND_ADDR) inPort.listen() inOutPort.initialize() outPort.connect() event = 'foo' outPort.send(event) self.assertEqual(event, inOutPort.receive(1.0)) event2 = 'bar' inOutPort.send(event2) self.assertEqual(event2, inPort.receive(1.0)) inPort.dispose() inOutPort.dispose()