def test_upload_from_file_failure(self):
    import requests
    from google.resumable_media import InvalidResponse
    from google.cloud import exceptions
    message = b'Someone is already in this spot.'
    response = requests.Response()
    response._content = message
    response.status_code = http_client.CONFLICT
    response.request = requests.Request('POST', 'http://example.com').prepare()
    side_effect = InvalidResponse(response)
    with self.assertRaises(exceptions.Conflict) as exc_info:
        self._upload_from_file_helper(side_effect=side_effect)
    self.assertIn(message.decode('utf-8'), exc_info.exception.message)
    self.assertEqual(exc_info.exception.errors, [])
def test_upload_from_file_failure(self):
    import requests
    from google.resumable_media import InvalidResponse
    from google.cloud import exceptions
    message = b'Someone is already in this spot.'
    response = requests.Response()
    response._content = message
    response.status_code = http_client.CONFLICT
    response.request = requests.Request('POST', 'http://example.com').prepare()
    side_effect = InvalidResponse(response)
    with self.assertRaises(exceptions.Conflict) as exc_info:
        self._upload_from_file_helper(side_effect=side_effect)
    self.assertIn(message.decode('utf-8'), exc_info.exception.message)
    self.assertEqual(exc_info.exception.errors, [])