Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add /datastore/ in emulator URI path. #1709

Merged
merged 1 commit into from
Apr 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions gcloud/datastore/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ class Connection(connection.Connection):
def __init__(self, credentials=None, http=None, api_base_url=None):
super(Connection, self).__init__(credentials=credentials, http=http)
if api_base_url is None:
api_base_url = os.getenv(GCD_HOST,
self.__class__.API_BASE_URL)
try:
# gcd.sh has /datastore/ in the path still since it supports
# v1beta2 and v1beta3 simultaneously.
api_base_url = '%s/datastore' % (os.environ[GCD_HOST],)
except KeyError:
api_base_url = self.__class__.API_BASE_URL
self.api_base_url = api_base_url

def _request(self, project, method, data):
Expand Down
8 changes: 4 additions & 4 deletions gcloud/datastore/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ def test_custom_url_from_env(self):
from gcloud.connection import API_BASE_URL
from gcloud.environment_vars import GCD_HOST

HOST = object()
HOST = 'CURR_HOST'
fake_environ = {GCD_HOST: HOST}

with _Monkey(os, getenv=fake_environ.get):
with _Monkey(os, environ=fake_environ):
conn = self._makeOne()

self.assertNotEqual(conn.api_base_url, API_BASE_URL)
self.assertEqual(conn.api_base_url, HOST)
self.assertEqual(conn.api_base_url, HOST + '/datastore')

def test_custom_url_from_constructor(self):
from gcloud.connection import API_BASE_URL
Expand All @@ -84,7 +84,7 @@ def test_custom_url_constructor_and_env(self):
HOST2 = object()
fake_environ = {GCD_HOST: HOST1}

with _Monkey(os, getenv=fake_environ.get):
with _Monkey(os, environ=fake_environ):
conn = self._makeOne(api_base_url=HOST2)

self.assertNotEqual(conn.api_base_url, API_BASE_URL)
Expand Down