Ejemplo n.º 1
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.º 2
0
class TimeMock(object):
    '''Object of this class encapsulates original time module interface'''
    def __init__(self, outUnixAddr, inUnixAddr):
        self._inOutPort = Port(outUnixAddr, inUnixAddr)

    def initialize(self):
        self._inOutPort.initialize()

    def dispose(self):
        self._inOutPort.dispose()

    def __getattr__(self, item):
        if hasattr(time, item):
            def rpcWrapper(*args, **kw):
                operation = item
                self._inOutPort.send({'method' : item, 'args' : args, 'kw' : kw})
                ret = self._inOutPort.receive(2.0)
                return ret
            return rpcWrapper
        return getattr(self, item)
Ejemplo n.º 3
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()