Exemplo n.º 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)
Exemplo n.º 2
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
Exemplo n.º 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)
Exemplo n.º 4
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)
Exemplo n.º 5
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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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
Exemplo n.º 11
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
Exemplo n.º 12
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
Exemplo n.º 13
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"
Exemplo n.º 14
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'
Exemplo n.º 15
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'
Exemplo n.º 16
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
Exemplo n.º 17
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