def testListSuccessful(self): """Tests successful List call.""" responses = [ self.storage_messages.Objects( items=[ self.storage_messages.Object(name='subdir/file_' + six.text_type(next_page_token) + '_' + six.text_type(i)) for i in range(5) ], nextPageToken=next_page_token) for next_page_token in ['foo', 'bar', None] ] expected_list_response = [] for response in responses: expected_list_response += response.items env_ref = parsers.ParseEnvironment(self.TEST_ENVIRONMENT_NAME) self.ExpectEnvironmentGet( self.TEST_PROJECT, self.TEST_LOCATION, self.TEST_ENVIRONMENT_ID, response=self.MakeEnvironmentWithBucket()) self.ExpectObjectList(self.test_gcs_bucket, 'subdir/', responses=responses) actual_list_response = storage_util.List( env_ref, 'subdir', release_track=self.track) six.assertCountEqual(self, expected_list_response, actual_list_response)
def testListStorageListFails(self): env_ref = parsers.ParseEnvironment(self.TEST_ENVIRONMENT_NAME) self.ExpectEnvironmentGet( self.TEST_PROJECT, self.TEST_LOCATION, self.TEST_ENVIRONMENT_ID, response=self.MakeEnvironmentWithBucket()) self.ExpectObjectList( self.test_gcs_bucket, 'subdir/', exception=http_error.MakeHttpError( code=403, message='PERMISSION_DENIED')) with self.AssertRaisesExceptionMatches( storage_api.ListBucketError, r'403 Could not list bucket [{}]: PERMISSION_DENIED'.format( self.test_gcs_bucket)): list(storage_util.List(env_ref, 'subdir', release_track=self.track))
def Run(self, args): env_ref = args.CONCEPTS.environment.Parse() return storage_util.List(env_ref, 'data')
def _Callback(): env_ref = parsers.ParseEnvironment(self.TEST_ENVIRONMENT_NAME) storage_util.List(env_ref, 'subdir', release_track=self.track)
def Run(self, args): env_ref = args.CONCEPTS.environment.Parse() return storage_util.List(env_ref, 'plugins', release_track=self.ReleaseTrack())