示例#1
0
 def test_connect_unixsocket(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res = yield from conn.execute(b'ping')
     self.assertTrue(res)
     self.assertTrue(conn._loop, self.loop)
     conn.close()
     yield from conn.wait_closed()
示例#2
0
 def test_failed_to_decode(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     with self.assertRaises(LookupError):
         yield from conn.execute(b'set', 1, b'fo', b'bar',
                                 encoding='utf-10')
     conn.close()
     yield from conn.wait_closed()
示例#3
0
 def test_encoding_property(self):
     conn = yield from create_connection(self.gibson_socket,
                                         encoding='utf-8',
                                         loop=self.loop)
     self.assertEqual(conn.encoding, 'utf-8')
     conn.close()
     yield from conn.wait_closed()
示例#4
0
 def test_connect_unixsocket(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res = yield from conn.execute(b'ping')
     self.assertTrue(res)
     self.assertTrue(conn._loop, self.loop)
     conn.close()
     yield from conn.wait_closed()
示例#5
0
 def test_cancel_futures_in_case_of_close(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res1 = conn.execute(b'ping')
     res2 = conn.execute(b'ping')
     conn.close()
     yield from conn.wait_closed()
     self.assertTrue(res1.cancelled)
     self.assertTrue(res2.cancelled)
示例#6
0
 def test_cancel_future_loop(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res = conn.execute(b'ping')
     res.cancel()
     res = yield from conn.execute(b'ping', encoding='utf-8')
     self.assertTrue(res)
     conn.close()
     yield from conn.wait_closed()
示例#7
0
 def test_global_loop(self):
     asyncio.set_event_loop(self.loop)
     conn = yield from create_connection(self.gibson_socket)
     res = yield from conn.execute(b'ping')
     self.assertTrue(conn._loop, self.loop)
     self.assertTrue(res)
     conn.close()
     yield from conn.wait_closed()
示例#8
0
 def test_cancel_futures_in_case_of_close(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res1 = conn.execute(b'ping')
     res2 = conn.execute(b'ping')
     conn.close()
     yield from conn.wait_closed()
     self.assertTrue(res1.cancelled)
     self.assertTrue(res2.cancelled)
示例#9
0
 def test_cancel_future_loop(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     res = conn.execute(b'ping')
     res.cancel()
     res = yield from conn.execute(b'ping', encoding='utf-8')
     self.assertTrue(res)
     conn.close()
     yield from conn.wait_closed()
示例#10
0
 def test_global_loop(self):
     asyncio.set_event_loop(self.loop)
     conn = yield from create_connection(self.gibson_socket)
     res = yield from conn.execute(b'ping')
     self.assertTrue(conn._loop, self.loop)
     self.assertTrue(res)
     conn.close()
     yield from conn.wait_closed()
示例#11
0
 def test_failed_to_decode(self):
     conn = yield from create_connection(self.gibson_socket, loop=self.loop)
     with self.assertRaises(LookupError):
         yield from conn.execute(b'set',
                                 1,
                                 b'fo',
                                 b'bar',
                                 encoding='utf-10')
     conn.close()
     yield from conn.wait_closed()
示例#12
0
    def test_execute(self):
        conn = yield from create_connection(self.gibson_socket, loop=self.loop)
        res = yield from conn.execute(b'ping')
        self.assertTrue(res)

        with self.assertRaises(TypeError):
            yield from conn.execute(None)

        with self.assertRaises(TypeError):
            yield from conn.execute(b'set', None)
        conn.close()
        yield from conn.wait_closed()
示例#13
0
    def test_execute(self):
        conn = yield from create_connection(self.gibson_socket, loop=self.loop)
        res = yield from conn.execute(b'ping')
        self.assertTrue(res)

        with self.assertRaises(TypeError):
            yield from conn.execute(None)

        with self.assertRaises(TypeError):
            yield from conn.execute(b'set', None)
        conn.close()
        yield from conn.wait_closed()
示例#14
0
 def test_encoding_property(self):
     conn = yield from create_connection(self.gibson_socket,
                                         encoding='utf-8', loop=self.loop)
     self.assertEqual(conn.encoding, 'utf-8')
     conn.close()
     yield from conn.wait_closed()
示例#15
0
 def test_protocol_error(self):
     with self.assertRaises(ProtocolError):
         conn = yield from create_connection(self.gibson_socket,
                                             loop=self.loop)
         conn._parser.feed(b'\x06\x00\x05\x03\x00\x00\x00bar')
         yield from conn.execute(b'ping')
示例#16
0
 def test_protocol_error(self):
     with self.assertRaises(ProtocolError):
         conn = yield from create_connection(self.gibson_socket,
                                             loop=self.loop)
         conn._parser.feed(b'\x06\x00\x05\x03\x00\x00\x00bar')
         yield from conn.execute(b'ping')