У меня есть предварительная настройка ловушки для запуска набора тестов для API Google Cloud Storage.Я могу смоделировать Google Build и запустить тесты отлично cloud-build-local --config=cloudbuild.yaml --dryrun=false .
.Однако при запуске ловушки перед фиксацией я получаю ошибку
google.auth.exceptions.DefaultCredentialsError: Could not automatically determine credentials. Please set GOOGLE_APPLICATION_CREDENTIALS or explicitly create credentials and re-run the application. For more information, please see https://cloud.google.com/docs/authentication/getting-started
Sample google_cloud_api.py
function
def list_blobs(bucket_name):
"""Returns list of names of all the blobs in the bucket."""
storage_client = storage.Client()
bucket = storage_client.get_bucket(bucket_name)
blobs = bucket.list_blobs()
return [blob.name for blob in blobs]
Sample test_google_cloud_api.py
function
def test_get_all_files():
blobs = google_cloud_storage_api.list_blobs(GCS_BUCKET_NAME)
for blob in blobs:
print(blob)