def test_recv_all_large(self): connection = Connection('host', 1) connection._sock = mock.MagicMock() buf = io.BytesIO((b'foo' * 1500) + b'\r\n') connection._sock.recv = lambda buf_size: buf.read(100) response = connection._recv_all() expected = ('foo' * 1500) + '\r\n' self.assertEqual(response, expected)
def test_recv_all_no_newline(self): connection = Connection('host', 1) connection._sock = mock.MagicMock() buf = io.BytesIO(b'foo') connection._sock.recv = lambda buf_size: buf.read() response = connection._recv_all() expected = 'foo' self.assertEqual(response, expected)
def test_noop(self): connection = Connection('host', 1) connection._sock = mock.MagicMock() buf = io.BytesIO(b'OK\r\n') connection._sock.recv = lambda buf_size: buf.read() connection.noop()