コード例 #1
0
  def test_TranslateApitoolsResumableUploadException(self):
    """Tests that _TranslateApitoolsResumableUploadException works correctly."""
    gsutil_api = GcsJsonApi(
        GSMockBucketStorageUri,
        CreateGsutilLogger('copy_test'))

    gsutil_api.http.disable_ssl_certificate_validation = True
    exc = apitools_exceptions.HttpError({'status': 503}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ServiceException))

    gsutil_api.http.disable_ssl_certificate_validation = False
    exc = apitools_exceptions.HttpError({'status': 503}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadException))

    exc = apitools_exceptions.HttpError({'status': 410}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc,
                               ResumableUploadStartOverException))

    exc = apitools_exceptions.HttpError({'status': 401}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))

    exc = apitools_exceptions.TransferError('Aborting transfer')
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))
コード例 #2
0
    def test_TranslateApitoolsResumableUploadException(self):
        """Tests that _TranslateApitoolsResumableUploadException works correctly."""
        gsutil_api = GcsJsonApi(GSMockBucketStorageUri,
                                CreateGsutilLogger('copy_test'))

        gsutil_api.http.disable_ssl_certificate_validation = True
        exc = apitools_exceptions.HttpError({'status': 503}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(isinstance(translated_exc, ServiceException))

        gsutil_api.http.disable_ssl_certificate_validation = False
        exc = apitools_exceptions.HttpError({'status': 503}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(isinstance(translated_exc, ResumableUploadException))

        exc = apitools_exceptions.HttpError({'status': 410}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadStartOverException))

        exc = apitools_exceptions.HttpError({'status': 401}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadAbortException))

        exc = apitools_exceptions.TransferError('Aborting transfer')
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadAbortException))
コード例 #3
0
    def testTranslateApitoolsResumableUploadException(self):
        """Tests that _TranslateApitoolsResumableUploadException works correctly."""
        gsutil_api = GcsJsonApi(GSMockBucketStorageUri,
                                CreateGsutilLogger('copy_test'),
                                DiscardMessagesQueue())

        gsutil_api.http.disable_ssl_certificate_validation = True
        exc = apitools_exceptions.HttpError({'status': 503}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(isinstance(translated_exc, ServiceException))

        gsutil_api.http.disable_ssl_certificate_validation = False
        exc = apitools_exceptions.HttpError({'status': 503}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(isinstance(translated_exc, ResumableUploadException))

        gsutil_api.http.disable_ssl_certificate_validation = False
        exc = apitools_exceptions.HttpError({'status': 429}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(isinstance(translated_exc, ResumableUploadException))

        exc = apitools_exceptions.HttpError({'status': 410}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadStartOverException))

        exc = apitools_exceptions.HttpError({'status': 404}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadStartOverException))

        exc = apitools_exceptions.HttpError({'status': 401}, None, None)
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadAbortException))

        exc = apitools_exceptions.TransferError('Aborting transfer')
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadAbortException))
        exc = apitools_exceptions.TransferError(
            'additional bytes left in stream')
        translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(
            exc)
        self.assertTrue(
            isinstance(translated_exc, ResumableUploadAbortException))
        self.assertIn('this can happen if a file changes size',
                      translated_exc.reason)
コード例 #4
0
 def testTranslateApitoolsResumableUploadExceptionStreamExhausted(self):
   """Test that StreamExhausted error gets handled."""
   gsutil_api = GcsJsonApi(GSMockBucketStorageUri,
                           CreateOrGetGsutilLogger('copy_test'),
                           DiscardMessagesQueue())
   exc = apitools_exceptions.StreamExhausted('Not enough bytes')
   translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
   self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))
   self.assertIn(
       'if this issue persists, try deleting the tracker files'
       ' present under ~/.gsutil/tracker-files/', translated_exc.reason)
コード例 #5
0
  def testTranslateApitoolsResumableUploadException(self):
    """Tests that _TranslateApitoolsResumableUploadException works correctly."""
    gsutil_api = GcsJsonApi(
        GSMockBucketStorageUri,
        CreateGsutilLogger('copy_test'),
        DiscardMessagesQueue())

    gsutil_api.http.disable_ssl_certificate_validation = True
    exc = apitools_exceptions.HttpError({'status': 503}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ServiceException))

    gsutil_api.http.disable_ssl_certificate_validation = False
    exc = apitools_exceptions.HttpError({'status': 503}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadException))

    gsutil_api.http.disable_ssl_certificate_validation = False
    exc = apitools_exceptions.HttpError({'status': 429}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadException))

    exc = apitools_exceptions.HttpError({'status': 410}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc,
                               ResumableUploadStartOverException))

    exc = apitools_exceptions.HttpError({'status': 404}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc,
                               ResumableUploadStartOverException))

    exc = apitools_exceptions.HttpError({'status': 401}, None, None)
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))

    exc = apitools_exceptions.TransferError('Aborting transfer')
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))
    exc = apitools_exceptions.TransferError('additional bytes left in stream')
    translated_exc = gsutil_api._TranslateApitoolsResumableUploadException(exc)
    self.assertTrue(isinstance(translated_exc, ResumableUploadAbortException))
    self.assertIn('this can happen if a file changes size',
                  translated_exc.reason)