def _create_resumable_upload_session_helper(self, origin=None, side_effect=None):
    bucket = mock.Mock(path='/b/alex-trebek', spec=[u'path'])
    blob = self._make_one('blob-name', bucket=bucket)
    chunk_size = (99 * blob._CHUNK_SIZE_MULTIPLE)
    blob.chunk_size = chunk_size
    resumable_url = 'http://test.invalid?upload_id=clean-up-everybody'
    response_headers = {'location': resumable_url}
    fake_transport = self._mock_transport(http_client.OK, response_headers)
    blob._make_transport = mock.Mock(return_value=fake_transport, spec=[])
    if (side_effect is not None):
        fake_transport.request.side_effect = side_effect
    content_type = u'text/plain'
    size = 10000
    client = mock.sentinel.client
    new_url = blob.create_resumable_upload_session(content_type=content_type, size=size, origin=origin, client=client)
    self.assertEqual(new_url, resumable_url)
    self.assertEqual(blob.chunk_size, chunk_size)
    blob._make_transport.assert_called_once_with(client)
    upload_url = (('https://www.googleapis.com/upload/storage/v1' + bucket.path) + '/o?uploadType=resumable')
    payload = b'{"name": "blob-name"}'
    expected_headers = {'content-type': 'application/json; charset=UTF-8', 'x-upload-content-length': str(size), 'x-upload-content-type': content_type}
    if (origin is not None):
        expected_headers['Origin'] = origin
    fake_transport.request.assert_called_once_with('POST', upload_url, data=payload, headers=expected_headers)
def _create_resumable_upload_session_helper(self, origin=None, side_effect=None):
    bucket = mock.Mock(path='/b/alex-trebek', spec=[u'path'])
    blob = self._make_one('blob-name', bucket=bucket)
    chunk_size = (99 * blob._CHUNK_SIZE_MULTIPLE)
    blob.chunk_size = chunk_size
    resumable_url = 'http://test.invalid?upload_id=clean-up-everybody'
    response_headers = {'location': resumable_url}
    fake_transport = self._mock_transport(http_client.OK, response_headers)
    blob._make_transport = mock.Mock(return_value=fake_transport, spec=[])
    if (side_effect is not None):
        fake_transport.request.side_effect = side_effect
    content_type = u'text/plain'
    size = 10000
    client = mock.sentinel.client
    new_url = blob.create_resumable_upload_session(content_type=content_type, size=size, origin=origin, client=client)
    self.assertEqual(new_url, resumable_url)
    self.assertEqual(blob.chunk_size, chunk_size)
    blob._make_transport.assert_called_once_with(client)
    upload_url = (('https://www.googleapis.com/upload/storage/v1' + bucket.path) + '/o?uploadType=resumable')
    payload = b'{"name": "blob-name"}'
    expected_headers = {'content-type': 'application/json; charset=UTF-8', 'x-upload-content-length': str(size), 'x-upload-content-type': content_type}
    if (origin is not None):
        expected_headers['Origin'] = origin
    fake_transport.request.assert_called_once_with('POST', upload_url, data=payload, headers=expected_headers)