Skip to content

Commit

Permalink
Merge pull request #672 from dhermes/fix-_implicit_environ-tests
Browse files Browse the repository at this point in the history
Unwinding cases in Test_set_default_dataset_id and having better test separation
  • Loading branch information
dhermes committed Feb 26, 2015
2 parents 808c38b + 1dd6709 commit d43c4a0
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 191 deletions.
14 changes: 12 additions & 2 deletions gcloud/datastore/_implicit_environ.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def compute_engine_id():
connection.close()


def _get_production_dataset_id():
"""Gets the production application ID if it can be inferred."""
return os.getenv(_DATASET_ENV_VAR_NAME)


def _get_gcd_dataset_id():
"""Gets the GCD application ID if it can be inferred."""
return os.getenv(_GCD_DATASET_ENV_VAR_NAME)


def _determine_default_dataset_id(dataset_id=None):
"""Determine default dataset ID explicitly or implicitly as fall-back.
Expand All @@ -104,10 +114,10 @@ def _determine_default_dataset_id(dataset_id=None):
:returns: Default dataset ID if it can be determined.
"""
if dataset_id is None:
dataset_id = os.getenv(_DATASET_ENV_VAR_NAME)
dataset_id = _get_production_dataset_id()

if dataset_id is None:
dataset_id = os.getenv(_GCD_DATASET_ENV_VAR_NAME)
dataset_id = _get_gcd_dataset_id()

if dataset_id is None:
dataset_id = app_engine_id()
Expand Down
Loading

0 comments on commit d43c4a0

Please sign in to comment.