Skip to content

Commit

Permalink
Merge pull request #1709 from dhermes/fix-1707
Browse files Browse the repository at this point in the history
Add /datastore/ in emulator URI path.
  • Loading branch information
dhermes committed Apr 8, 2016
2 parents ac50331 + 91bd475 commit 465976a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
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

0 comments on commit 465976a

Please sign in to comment.