def _upload_from_string_helper(self, data, **kwargs):
    from google.cloud._helpers import _to_bytes
    blob = self._make_one('blob-name', bucket=None)
    created_json = {'componentCount': '5'}
    blob._do_upload = mock.Mock(return_value=created_json, spec=[])
    self.assertIsNone(blob.component_count)
    client = mock.sentinel.client
    ret_val = blob.upload_from_string(data, client=client, **kwargs)
    self.assertIsNone(ret_val)
    self.assertEqual(blob.component_count, 5)
    payload = _to_bytes(data, encoding='utf-8')
    stream = self._do_upload_mock_call_helper(blob, client, 'text/plain', len(payload))
    self.assertIsInstance(stream, io.BytesIO)
    self.assertEqual(stream.getvalue(), payload)
def _upload_from_string_helper(self, data, **kwargs):
    from google.cloud._helpers import _to_bytes
    blob = self._make_one('blob-name', bucket=None)
    created_json = {'componentCount': '5'}
    blob._do_upload = mock.Mock(return_value=created_json, spec=[])
    self.assertIsNone(blob.component_count)
    client = mock.sentinel.client
    ret_val = blob.upload_from_string(data, client=client, **kwargs)
    self.assertIsNone(ret_val)
    self.assertEqual(blob.component_count, 5)
    payload = _to_bytes(data, encoding='utf-8')
    stream = self._do_upload_mock_call_helper(blob, client, 'text/plain', len(payload))
    self.assertIsInstance(stream, io.BytesIO)
    self.assertEqual(stream.getvalue(), payload)