def test_run_read(self):
        loop = RecocoIOLoop()
        (left, right) = MockSocket.pair()
        worker = loop.new_worker(left)

        # callback for ioworker to record receiving
        self.received = None

        def r(worker):
            self.received = worker.peek()

        worker.rx_handler = r

        # 'start' the run (dark generator magic here).
        # Does not actually execute run, but 'yield' a generator
        g = loop.run()
        # g.next() will call it, and get as far as the 'yield select'
        select = next(g)

        # send data on other socket half
        right.send(b"hallo")

        # now we emulate the return value of the select ([rlist],[wlist], [elist])
        g.send(([worker], [], []))

        # that should result in the socket being red the data being handed
        # to the ioworker, the callback being called. Everybody happy.
        self.assertEqual(self.received, b"hallo")
Example #2
0
  def test_run_read(self):
    loop = RecocoIOLoop()
    (left, right) = MockSocket.pair()
    worker = loop.new_worker(left)

    # callback for ioworker to record receiving
    self.received = None
    def r(worker):
      self.received = worker.peek()
    worker.rx_handler = r

    # 'start' the run (dark generator magic here).
    # Does not actually execute run, but 'yield' a generator
    g = loop.run()
    # g.next() will call it, and get as far as the 'yield select'
    select = g.next()

    # send data on other socket half
    right.send("hallo")

    # now we emulate the return value of the select ([rlist],[wlist], [elist])
    g.send(([worker], [], []))

    # that should result in the socket being red the data being handed
    # to the ioworker, the callback being called. Everybody happy.
    self.assertEquals(self.received, "hallo")
    def test_run_write(self):
        loop = RecocoIOLoop()
        (left, right) = MockSocket.pair()
        worker = loop.new_worker(left)

        worker.send(b"heppo")
        # 'start' the run (dark generator magic here).
        # Does not actually execute run, but 'yield' a generator
        g = loop.run()
        # g.next() will call it, and get as far as the 'yield select'
        select = next(g)

        # now we emulate the return value of the select ([rlist],[wlist], [elist])
        g.send(([], [worker], []))

        # that should result in the stuff being sent on the socket
        self.assertEqual(right.recv(), b"heppo")
Example #4
0
  def test_run_write(self):
    loop = RecocoIOLoop()
    (left, right) = MockSocket.pair()
    worker = loop.new_worker(left)

    worker.send("heppo")
    # 'start' the run (dark generator magic here).
    # Does not actually execute run, but 'yield' a generator
    g = loop.run()
    # g.next() will call it, and get as far as the 'yield select'
    select = g.next()

    # now we emulate the return value of the select ([rlist],[wlist], [elist])
    g.send(([], [worker], []))

    # that should result in the stuff being sent on the socket
    self.assertEqual(right.recv(), "heppo")