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=')
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)
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'), ))
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)
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`"), ))
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 />&')