Esempio n. 1
0
    def test_wait_for_auth(self):
        con = self._connection()
        p = Protocol(con, "foo")
        p._authed = True
        p._authed_event.set()

        p._wait_for_auth()
Esempio n. 2
0
    def test_wait_for_auth(self):
        con = self._connection()
        p = Protocol(con, "foo")
        p._authed = True
        p._authed_event.set()

        p._wait_for_auth()
Esempio n. 3
0
    def test_request_async(self):
        con = self._with_pck((MSG_RESPONSE, self._response_data))

        p = Protocol(con, "foo")
        p._authed = True

        args = dict(somearg=sentinel.somearg)
        handle = p.request(sentinel.mtd, **args)

        p._loop()

        # calling handle should wait the response
        ret = handle()

        eq_(ret, "foo")
        con.send_packet.assert_called_once_with(MSG_REQUEST, {
            "reqid": 1,
            "action": sentinel.mtd,
            "args": args
        })
Esempio n. 4
0
    def test_request_async(self):
        con = self._with_pck((MSG_RESPONSE, self._response_data))

        p = Protocol(con, "foo")
        p._authed = True

        args = dict(somearg=sentinel.somearg)
        handle = p.request(sentinel.mtd, **args)

        p._loop()

        # calling handle should wait the response
        ret = handle()

        eq_(ret, "foo")
        con.send_packet.assert_called_once_with(MSG_REQUEST, {
            "reqid": 1,
            "action": sentinel.mtd,
            "args": args
            })
Esempio n. 5
0
    def test_request_sync(self):
        con = self._with_pck((MSG_RESPONSE, self._response_data))

        p = Protocol(con, "foo")
        p._authed = True

        def fn():
            time.sleep(0.001)
            p._loop()

        th = gevent.Greenlet(fn)
        th.start()

        args = dict(somearg=sentinel.somearg)
        ret = p.request_sync(sentinel.mtd, timeout=1, **args)

        eq_(ret, "foo")
        con.send_packet.assert_called_once_with(MSG_REQUEST, {
            "reqid": 1,
            "action": sentinel.mtd,
            "args": args
        })
        th.join()
Esempio n. 6
0
    def test_request_sync(self):
        con = self._with_pck((MSG_RESPONSE, self._response_data))

        p = Protocol(con, "foo")
        p._authed = True

        def fn():
            time.sleep(0.001)
            p._loop()

        th = gevent.Greenlet(fn)
        th.start()

        args = dict(somearg=sentinel.somearg)
        ret = p.request_sync(sentinel.mtd, timeout=1, **args)

        eq_(ret, "foo")
        con.send_packet.assert_called_once_with(MSG_REQUEST, {
            "reqid": 1,
            "action": sentinel.mtd,
            "args": args
            })
        th.join()