def testProjectAclChangesOnBucket(self):
    if self.test_api == ApiSelector.XML:
      stderr = self.RunGsUtil(self._ch_acl_prefix +
                              ['-p', self._project_test_acl +':w',
                               suri(self.sample_uri)],
                              expected_status=1,
                              return_stderr=True)
      self.assertIn(('CommandException: XML API does not support project'
                     ' scopes, cannot translate ACL.'), stderr)
    else:
      test_regex = self._MakeProjectScopeRegex(
          'WRITER', self._project_team)
      self.RunGsUtil(self._ch_acl_prefix +
                     ['-p', self._project_test_acl +':w',
                      suri(self.sample_uri)])
      json_text = self.RunGsUtil(
          self._get_acl_prefix + [suri(self.sample_uri)], return_stdout=True)

      self.assertRegexpMatches(json_text, test_regex)

      # The api will accept string project ids, but stores the numeric project
      # ids internally, this extracts the numeric id from the returned acls.
      proj_num_id = test_regex.search(json_text).group(1)
      acl_to_remove = '%s-%s' % (self._project_team, proj_num_id)

      self.RunGsUtil(self._ch_acl_prefix +
                     ['-d', acl_to_remove, suri(self.sample_uri)])

      json_text2 = self.RunGsUtil(
          self._get_acl_prefix + [suri(self.sample_uri)], return_stdout=True)
      self.assertNotRegexpMatches(json_text2, test_regex)
Tests project entity acl changes on a bucket.
dataset/ETHPy150Open GoogleCloudPlatform/gsutil/gslib/tests/test_acl.py/TestAcl.testProjectAclChangesOnBucket