def testStreamMediaCompressedFail(self): """Test that non-chunked uploads raise an exception. Ensure uploads with the compressed and resumable flags set called from StreamMedia raise an exception. Those uploads are unsupported. """ # Create the upload object. upload = transfer.Upload( stream=self.sample_stream, mime_type='text/plain', total_size=len(self.sample_data), close_stream=False, auto_transfer=True, gzip_encoded=True) upload.strategy = transfer.RESUMABLE_UPLOAD # Mock the upload to return the sample response. with mock.patch.object(http_wrapper, 'MakeRequest') as make_request: make_request.return_value = self.response # Initialization. upload.InitializeUpload(self.request, 'http') # Ensure stream media raises an exception when the upload is # compressed. Compression is not supported on non-chunked uploads. with self.assertRaises(exceptions.InvalidUserInputError): upload.StreamMedia()