Use "gcloud config config-helper" to read the project ID from the Google Cloud SDK (#147)
diff --git a/system_tests/nox.py b/system_tests/nox.py
index 0d1116d..fa0422a 100644
--- a/system_tests/nox.py
+++ b/system_tests/nox.py
@@ -85,6 +85,11 @@
session.env[CLOUD_SDK_CONFIG_ENV] = str(CLOUD_SDK_ROOT)
# This tells gcloud which Python interpreter to use (always use 2.7)
session.env[CLOUD_SDK_PYTHON_ENV] = CLOUD_SDK_PYTHON
+ # This set the $PATH for the subprocesses so they can find the gcloud
+ # executable.
+ session.env['PATH'] = (
+ str(CLOUD_SDK_INSTALL_DIR.join('bin')) + os.pathsep +
+ os.environ['PATH'])
# If gcloud cli executable already exists, just update it.
if py.path.local(GCLOUD).exists():
@@ -130,6 +135,14 @@
"""
install_cloud_sdk(session)
+ # Setup the service account as the default user account. This is
+ # needed for the project ID detection to work. Note that this doesn't
+ # change the application default credentials file, which is user
+ # credentials instead of service account credentials sometimes.
+ session.run(
+ GCLOUD, 'auth', 'activate-service-account', '--key-file',
+ SERVICE_ACCOUNT_FILE)
+
if project:
session.run(GCLOUD, 'config', 'set', 'project', 'example-project')
else: