Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
    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()
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
    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()
Ejemplo n.º 8
0
    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()