Ejemplo n.º 1
0
    def test_write_no_data(self, mock_http):
        dfw = DiskFileWriter(make_client_collection(), 'obj',
                             logger=logging.root)

        written = dfw.write("")

        self.assertEqual(0, written)
        fake_http_conn = mock_http.return_value[0]
        self.assertEqual('0\r\n\r\n', fake_http_conn._buffer.getvalue())
Ejemplo n.º 2
0
    def test_write_no_data(self, mock_http):
        dfw = DiskFileWriter(make_client_collection(),
                             'obj',
                             logger=logging.root)

        written = dfw.write("")

        self.assertEqual(0, written)
        fake_http_conn = mock_http.return_value[0]
        self.assertEqual('0\r\n\r\n', fake_http_conn._buffer.getvalue())
Ejemplo n.º 3
0
    def test_write_with_data(self, mock_http):
        dfw = DiskFileWriter(make_client_collection(), 'obj',
                             logger=logging.root)

        data = "a" * 4096
        written = dfw.write(data)

        self.assertEqual(len(data), written)
        fake_http_conn = mock_http.return_value[0]
        self.assertEqual('%x\r\n%s\r\n' % (len(data), data),
                         fake_http_conn._buffer.getvalue())
Ejemplo n.º 4
0
    def test_write_with_data(self, mock_http):
        dfw = DiskFileWriter(make_client_collection(),
                             'obj',
                             logger=logging.root)

        data = "a" * 4096
        written = dfw.write(data)

        self.assertEqual(len(data), written)
        fake_http_conn = mock_http.return_value[0]
        self.assertEqual('%x\r\n%s\r\n' % (len(data), data),
                         fake_http_conn._buffer.getvalue())