Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions firestore/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def system(session):
system_test_path = os.path.join("tests", "system.py")
system_test_folder_path = os.path.join("tests", "system")
# Sanity check: Only run tests if the environment variable is set.
if not os.environ.get("FIRESTORE_APPLICATION_CREDENTIALS", ""):
session.skip("Credentials must be set via environment variable")
if not os.getenv("FIRESTORE_EMULATOR_HOST"):
if not os.environ.get("FIRESTORE_APPLICATION_CREDENTIALS", ""):
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pay attention! Nox files are generated automatically. Your changes are incorrect and must be rethought.
https://github.com/q-logic/google-cloud-python/blob/f81bf63abf64ab297bff6057b91d1e7cf6576dd6/firestore/noxfile.py#L16-L18

Copy link
Copy Markdown
Author

@sumit-ql sumit-ql Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, will revert it. Thanks!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted the nox file for now, but i need those changes in nox file.
Should I exclude the noxfile.py from synth tool?

session.skip("Credentials must be set via environment variable")

system_test_exists = os.path.exists(system_test_path)
system_test_folder_exists = os.path.exists(system_test_folder_path)
Expand Down
12 changes: 9 additions & 3 deletions firestore/tests/system/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from google.cloud._helpers import UTC
from google.cloud import firestore_v1 as firestore
from test_utils.system import unique_resource_id
from test_utils.system import EmulatorCreds

from time import sleep

Expand All @@ -40,12 +41,17 @@
MISSING_DOCUMENT = "No document to update: "
DOCUMENT_EXISTS = "Document already exists: "
UNIQUE_RESOURCE_ID = unique_resource_id("-")

FIRESTORE_EMULATOR_HOST = "FIRESTORE_EMULATOR_HOST"

@pytest.fixture(scope=u"module")
def client():
credentials = service_account.Credentials.from_service_account_file(FIRESTORE_CREDS)
project = FIRESTORE_PROJECT or credentials.project_id
firestore_emulator = os.getenv(FIRESTORE_EMULATOR_HOST)
if firestore_emulator is not None:
credentials = EmulatorCreds()
project = "emulatorproject"
else:
credentials = service_account.Credentials.from_service_account_file(FIRESTORE_CREDS)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lint session fails! Use black to reformat the file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

project = FIRESTORE_PROJECT or credentials.project_id
yield firestore.Client(project=project, credentials=credentials)


Expand Down