def test_buffered_exception_is_caught(self): raw_transport = metrics.RawTransport(EXAMPLE_ENDPOINT) transport = metrics.BufferedTransport(raw_transport) transport.send(b"x" * 65536) with self.assertRaises(metrics.MessageTooBigTransportError): transport.flush()
def test_buffered(self, mock_make_socket): mocket = mock_make_socket.return_value raw_transport = metrics.RawTransport(EXAMPLE_ENDPOINT) transport = metrics.BufferedTransport(raw_transport) transport.send(b"a") transport.send(b"b") transport.send(b"c") self.assertEqual(mocket.sendall.call_count, 0) transport.flush() self.assertEqual(mocket.sendall.call_count, 1) self.assertEqual(mocket.sendall.call_args, mock.call(b"a\nb\nc"))