Esempio n. 1
0
    def test_params_converting(self, *args):
        c = Client()
        c._socket.send_recv.return_value = b'200 OK\n'

        with self.subTest(type=bool):
            c.call('PING', {'key': True})
            c._socket.send_recv.assert_called_with(b'PING key=1')

        with self.subTest(type=None):
            c.call('PING', {'key': None})
            c._socket.send_recv.assert_called_with(b'PING key=')
Esempio n. 2
0
 def test_empty_data(self, *args):
     c = Client()
     c._socket.send_recv.return_value = b'200 OK'
     resp = c.call('PING', {'key': 'value'})
     c._socket.send_recv.assert_called_with(b'PING key=value')
     self.assertEqual(resp.code, 200)
     self.assertEqual(resp.message, 'OK')
     self.assertFalse(resp.data)
Esempio n. 3
0
 def test_single_data(self, *args):
     c = Client()
     c._socket.send_recv.return_value = b'200 OK\nA|B|C'
     resp = c.call('PING', {'key': 'value'})
     c._socket.send_recv.assert_called_with(b'PING key=value')
     self.assertEqual(resp.code, 200)
     self.assertEqual(resp.message, 'OK')
     self.assertTupleEqual(resp.data, (('A', 'B', 'C'), ))
Esempio n. 4
0
 def test_send_recv_none(self, *args):
     c = Client(None, None, None)
     c._socket._socket.recv.return_value = b'200 OK'
     c.call('PING')
     c._socket._socket.sendto.assert_called_with(b'PING', Client.SERVER)
Esempio n. 5
0
 def test_unescape(self, *args):
     c = Client()
     c._socket.send_recv.return_value = b'200 OK\nmulti<br />line|pi/pe|`apo`'
     resp = c.call('PING')
     self.assertTupleEqual(resp.data, (('multi\nline', 'pi/pe', "`apo`"), ))
Esempio n. 6
0
 def test_escape(self, *args):
     c = Client()
     c._socket.send_recv.return_value = b'200 OK'
     c.call('PING', {'key': 'line\n&'})
     c._socket.send_recv.assert_called_with(b'PING key=line<br />&amp;')