transfer_test_14.py 1.1 KB

123456789101112131415161718192021222324252627
  1. def testStreamMediaCompressedFail(self):
  2. """Test that non-chunked uploads raise an exception.
  3. Ensure uploads with the compressed and resumable flags set called from
  4. StreamMedia raise an exception. Those uploads are unsupported.
  5. """
  6. # Create the upload object.
  7. upload = transfer.Upload(
  8. stream=self.sample_stream,
  9. mime_type='text/plain',
  10. total_size=len(self.sample_data),
  11. close_stream=False,
  12. auto_transfer=True,
  13. gzip_encoded=True)
  14. upload.strategy = transfer.RESUMABLE_UPLOAD
  15. # Mock the upload to return the sample response.
  16. with mock.patch.object(http_wrapper,
  17. 'MakeRequest') as make_request:
  18. make_request.return_value = self.response
  19. # Initialization.
  20. upload.InitializeUpload(self.request, 'http')
  21. # Ensure stream media raises an exception when the upload is
  22. # compressed. Compression is not supported on non-chunked uploads.
  23. with self.assertRaises(exceptions.InvalidUserInputError):
  24. upload.StreamMedia()