def _do_multipart_success(self, mock_get_boundary, size=None, num_retries=None):
    bucket = mock.Mock(path='/b/w00t', spec=[u'path'])
    blob = self._make_one(u'blob-name', bucket=bucket)
    self.assertIsNone(blob.chunk_size)
    fake_transport = self._mock_transport(http_client.OK, {})
    blob._make_transport = mock.Mock(return_value=fake_transport, spec=[])
    client = mock.sentinel.client
    data = b'data here hear hier'
    stream = io.BytesIO(data)
    content_type = u'application/xml'
    response = blob._do_multipart_upload(client, stream, content_type, size, num_retries)
    self.assertIs(response, fake_transport.request.return_value)
    if (size is None):
        data_read = data
        self.assertEqual(stream.tell(), len(data))
    else:
        data_read = data[:size]
        self.assertEqual(stream.tell(), size)
    blob._make_transport.assert_called_once_with(client)
    mock_get_boundary.assert_called_once_with()
    upload_url = (('https://www.googleapis.com/upload/storage/v1' + bucket.path) + '/o?uploadType=multipart')
    payload = ((((((b'--==0==\r\n' + b'content-type: application/json; charset=UTF-8\r\n\r\n') + b'{"name": "blob-name"}\r\n') + b'--==0==\r\n') + b'content-type: application/xml\r\n\r\n') + data_read) + b'\r\n--==0==--')
    headers = {'content-type': b'multipart/related; boundary="==0=="'}
    fake_transport.request.assert_called_once_with('POST', upload_url, data=payload, headers=headers)
def _do_multipart_success(self, mock_get_boundary, size=None, num_retries=None):
    bucket = mock.Mock(path='/b/w00t', spec=[u'path'])
    blob = self._make_one(u'blob-name', bucket=bucket)
    self.assertIsNone(blob.chunk_size)
    fake_transport = self._mock_transport(http_client.OK, {})
    blob._make_transport = mock.Mock(return_value=fake_transport, spec=[])
    client = mock.sentinel.client
    data = b'data here hear hier'
    stream = io.BytesIO(data)
    content_type = u'application/xml'
    response = blob._do_multipart_upload(client, stream, content_type, size, num_retries)
    self.assertIs(response, fake_transport.request.return_value)
    if (size is None):
        data_read = data
        self.assertEqual(stream.tell(), len(data))
    else:
        data_read = data[:size]
        self.assertEqual(stream.tell(), size)
    blob._make_transport.assert_called_once_with(client)
    mock_get_boundary.assert_called_once_with()
    upload_url = (('https://www.googleapis.com/upload/storage/v1' + bucket.path) + '/o?uploadType=multipart')
    payload = ((((((b'--==0==\r\n' + b'content-type: application/json; charset=UTF-8\r\n\r\n') + b'{"name": "blob-name"}\r\n') + b'--==0==\r\n') + b'content-type: application/xml\r\n\r\n') + data_read) + b'\r\n--==0==--')
    headers = {'content-type': b'multipart/related; boundary="==0=="'}
    fake_transport.request.assert_called_once_with('POST', upload_url, data=payload, headers=headers)