Beispiel #1
0
 def test_conn_socket_upgrade(self):
     c = AsyncConn("127.0.0.1", 4150, io_loop=self.io_loop, **self.identify_options)
     c.on("ready", self.stop)
     c.connect()
     self.wait()
     assert isinstance(c.socket, DeflateSocket)
     assert isinstance(c.socket._socket, ssl.SSLSocket)
Beispiel #2
0
 def test_conn_identify(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop)
     c.on('identify_response', self.stop)
     c.connect()
     response = self.wait()
     print response
     assert response['conn'] is c
     assert isinstance(response['data'], dict)
Beispiel #3
0
 def test_conn_identify(self):
     c = AsyncConn("127.0.0.1", 4150, io_loop=self.io_loop)
     c.on("identify_response", self.stop)
     c.connect()
     response = self.wait()
     print(response)
     assert response["conn"] is c
     assert isinstance(response["data"], dict)
Beispiel #4
0
 def test_conn_socket_upgrade(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                   **self.identify_options)
     c.on('ready', self.stop)
     c.connect()
     self.wait()
     assert isinstance(c.socket, SnappySocket)
     assert isinstance(c.socket._socket, ssl.SSLSocket)
Beispiel #5
0
    def _send_messages(self, topic, count, body):
        c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop)
        c.connect()

        def _on_ready(*args, **kwargs):
            for i in range(count):
                c.send(protocol.pub(topic, body))

        c.on('ready', _on_ready)
Beispiel #6
0
 def test_conn_identify_options(self):
     c = AsyncConn("127.0.0.1", 4150, io_loop=self.io_loop, **self.identify_options)
     c.on("identify_response", self.stop)
     c.connect()
     response = self.wait()
     print(response)
     assert response["conn"] is c
     assert isinstance(response["data"], dict)
     assert response["data"]["snappy"] is True
     assert response["data"]["tls_v1"] is True
Beispiel #7
0
 def test_conn_identify_options(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                   **self.identify_options)
     c.on('identify_response', self.stop)
     c.connect()
     response = self.wait()
     print response
     assert response['conn'] is c
     assert isinstance(response['data'], dict)
     assert response['data']['snappy'] is True
     assert response['data']['tls_v1'] is True
Beispiel #8
0
    def test_conn_subscribe(self):
        topic = "test_conn_suscribe_%s" % time.time()
        c = AsyncConn("127.0.0.1", 4150, io_loop=self.io_loop, **self.identify_options)

        def _on_ready(*args, **kwargs):
            c.on("response", self.stop)
            c.send(protocol.subscribe(topic, "ch"))

        c.on("ready", _on_ready)
        c.connect()
        response = self.wait()
        print(response)
        assert response["conn"] is c
        assert response["data"] == b"OK"
Beispiel #9
0
    def test_conn_subscribe(self):
        topic = 'test_conn_suscribe_%s' % time.time()
        c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                      **self.identify_options)

        def _on_ready(*args, **kwargs):
            c.on('response', self.stop)
            c.send(protocol.subscribe(topic, 'ch'))

        c.on('ready', _on_ready)
        c.connect()
        response = self.wait()
        print response
        assert response['conn'] is c
        assert response['data'] == 'OK'
Beispiel #10
0
    def test_conn_messages(self):
        self.msg_count = 0

        topic = 'test_conn_suscribe_%s' % time.time()
        self._send_messages(topic, 5, 'sup')

        c = AsyncConn('127.0.0.1',
                      4150,
                      io_loop=self.io_loop,
                      **self.identify_options)

        def _on_message(*args, **kwargs):
            self.msg_count += 1
            if c.rdy == 0:
                self.stop()

        def _on_ready(*args, **kwargs):
            c.on('message', _on_message)
            c.send(protocol.subscribe(topic, 'ch'))
            c.send_rdy(5)

        c.on('ready', _on_ready)
        c.connect()

        self.wait()
        assert self.msg_count == 5
Beispiel #11
0
 def test_conn_socket_upgrade(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                   **self.identify_options)
     c.on('ready', self.stop)
     c.connect()
     self.wait()
     assert isinstance(c.socket, DeflateSocket)
     assert isinstance(c.socket._socket, ssl.SSLSocket)
Beispiel #12
0
 def test_conn_identify(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop)
     c.on('identify_response', self.stop)
     c.connect()
     response = self.wait()
     print response
     assert response['conn'] is c
     assert isinstance(response['data'], dict)
Beispiel #13
0
    def test_conn_messages(self):
        self.msg_count = 0

        topic = "test_conn_suscribe_%s" % time.time()
        self._send_messages(topic, 5, b"sup")

        c = AsyncConn("127.0.0.1", 4150, io_loop=self.io_loop, **self.identify_options)

        def _on_message(*args, **kwargs):
            self.msg_count += 1
            if c.rdy == 0:
                self.stop()

        def _on_ready(*args, **kwargs):
            c.on("message", _on_message)
            c.send(protocol.subscribe(topic, "ch"))
            c.send_rdy(5)

        c.on("ready", _on_ready)
        c.connect()

        self.wait()
        assert self.msg_count == 5
Beispiel #14
0
    def _send_messages(self, topic, count, body):
        c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop)
        c.connect()

        def _on_ready(*args, **kwargs):
            for i in range(count):
                c.send(protocol.pub(topic, body))

        c.on('ready', _on_ready)
Beispiel #15
0
    def test_conn_messages(self):
        self.msg_count = 0

        topic = 'test_conn_suscribe_%s' % time.time()
        self._send_messages(topic, 5, 'sup')

        c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                      **self.identify_options)

        def _on_message(*args, **kwargs):
            self.msg_count += 1
            if c.rdy == 0:
                self.stop()

        def _on_ready(*args, **kwargs):
            c.on('message', _on_message)
            c.send(protocol.subscribe(topic, 'ch'))
            c.send_rdy(5)

        c.on('ready', _on_ready)
        c.connect()

        self.wait()
        assert self.msg_count == 5
Beispiel #16
0
 def test_conn_identify_options(self):
     c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                   **self.identify_options)
     c.on('identify_response', self.stop)
     c.connect()
     response = self.wait()
     print(response)
     assert response['conn'] is c
     assert isinstance(response['data'], dict)
     assert response['data']['deflate'] is True
     assert response['data']['tls_v1'] is True
Beispiel #17
0
    def test_conn_subscribe(self):
        topic = 'test_conn_suscribe_%s' % time.time()
        c = AsyncConn('127.0.0.1', 4150, io_loop=self.io_loop,
                      **self.identify_options)

        def _on_ready(*args, **kwargs):
            c.on('response', self.stop)
            c.send(protocol.subscribe(topic, 'ch'))

        c.on('ready', _on_ready)
        c.connect()
        response = self.wait()
        print(response)
        assert response['conn'] is c
        assert response['data'] == b'OK'
Beispiel #18
0
def _get_test_conn(io_loop=None):
    conn = AsyncConn('test', 4150, io_loop=io_loop)
    # now set the stream attribute, which is ordinarily set in conn.connect()
    conn.stream = create_autospec(IOStream)
    return conn
Beispiel #19
0
def _get_test_conn(io_loop=None):
    conn = AsyncConn('test', 4150, io_loop=io_loop)
    # now set the stream attribute, which is ordinarily set in conn.connect()
    conn.stream = create_autospec(IOStream)
    return conn