# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# 
# Path: gslib/exception.py
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForS3(reason):
#   if RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func


import os
import re
import sys
import gslib.tests.testcase as testcase
import gslib.tests.util as util
from unittest import mock
from gslib.exception import NO_URLS_MATCHED_PREFIX
from gslib.exception import NO_URLS_MATCHED_TARGET
from gslib.tests.testcase.base import MAX_BUCKET_LENGTH
from gslib.tests.testcase.integration_testcase import SkipForS3
from gslib.tests.util import GenerationFromURI as urigen
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import SetBotoConfigForTest
from gslib.tests.util import SetEnvironmentForTest
from gslib.utils.retry_util import Retry
           suri(object_uri)],
          expected_status=1)
    stderr = self.RunGsUtil(
        ['rm', '-f',
         '%s' % suri(bucket_uri, 'missing'),
         suri(object_uri)],
        return_stderr=True,
        expected_status=1)
    self.assertEqual(stderr.count('Removing %s://' % self.default_provider), 1)
    self.RunGsUtil(['stat', suri(object_uri)], expected_status=1)

  def test_some_missing(self):
    """Test that 'rm -a' fails when some but not all uris don't exist."""
    bucket_uri = self.CreateVersionedBucket()
    key_uri = self.StorageUriCloneReplaceName(bucket_uri, 'foo')
    self.StorageUriSetContentsFromString(key_uri, 'bar')
    if self.multiregional_buckets:
      self.AssertNObjectsInBucket(bucket_uri, 1, versioned=True)
    stderr = self.RunGsUtil(
        ['rm', '-a',
         suri(key_uri),
         '%s' % suri(bucket_uri, 'missing')],
        return_stderr=True,
        expected_status=1)
    self.assertEqual(stderr.count('Removing %s://' % self.default_provider), 1)
    if self._use_gcloud_storage:
      self.assertIn(
          'URL matched no objects or files: %s' % suri(bucket_uri, 'missing'),
          stderr)
    else:

# Path: gslib/exception.py
# NO_URLS_MATCHED_PREFIX = 'No URLs matched'
# 
# Path: gslib/exception.py
# NO_URLS_MATCHED_TARGET = NO_URLS_MATCHED_PREFIX + ': %s'
# 
# Path: gslib/tests/testcase/integration_testcase.py
# def SkipForS3(reason):
#   if RUN_S3_TESTS:
#     return unittest.skip(reason)
#   else:
#     return lambda func: func


# Path: gslib/tests/test_rm.py
import os
import re
import sys
import gslib.tests.testcase as testcase
import gslib.tests.util as util
from unittest import mock
from gslib.exception import NO_URLS_MATCHED_PREFIX
from gslib.exception import NO_URLS_MATCHED_TARGET
from gslib.tests.testcase.base import MAX_BUCKET_LENGTH
from gslib.tests.testcase.integration_testcase import SkipForS3
from gslib.tests.util import GenerationFromURI as urigen
from gslib.tests.util import ObjectToURI as suri
from gslib.tests.util import SetBotoConfigForTest
from gslib.tests.util import SetEnvironmentForTest
from gslib.utils.retry_util import Retry

           suri(object_uri)],
          expected_status=1)
    stderr = self.RunGsUtil(
        ['rm', '-f',
         '%s' % suri(bucket_uri, 'missing'),
         suri(object_uri)],
        return_stderr=True,
        expected_status=1)
    self.assertEqual(stderr.count('Removing %s://' % self.default_provider), 1)
    self.RunGsUtil(['stat', suri(object_uri)], expected_status=1)

  def test_some_missing(self):
    """Test that 'rm -a' fails when some but not all uris don't exist."""
    bucket_uri = self.CreateVersionedBucket()
    key_uri = self.StorageUriCloneReplaceName(bucket_uri, 'foo')
    self.StorageUriSetContentsFromString(key_uri, 'bar')
    if self.multiregional_buckets:
      self.AssertNObjectsInBucket(bucket_uri, 1, versioned=True)
    stderr = self.RunGsUtil(
        ['rm', '-a',
         suri(key_uri),
         '%s' % suri(bucket_uri, 'missing')],
        return_stderr=True,
        expected_status=1)
    self.assertEqual(stderr.count('Removing %s://' % self.default_provider), 1)
    if self._use_gcloud_storage:
      self.assertIn(
          'URL matched no objects or files: %s' % suri(bucket_uri, 'missing'),
          stderr)
    else:

      self.assertIn(NO_URLS_MATCHED_TARGET % suri(bucket_uri, 'missing'),