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

Changing use of PUBSUB_HOST env. var. to PUBSUB_EMULATOR_HOST. #1371

Merged
merged 1 commit into from
Jan 14, 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
2 changes: 1 addition & 1 deletion gcloud/environment_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
GCD_HOST = 'DATASTORE_HOST'
"""Environment variable defining host for GCD dataset server."""

PUBSUB_EMULATOR = 'PUBSUB_HOST'
PUBSUB_EMULATOR = 'PUBSUB_EMULATOR_HOST'
"""Environment variable defining host for Pub/Sub emulator."""

TESTS_DATASET = 'GCLOUD_TESTS_DATASET_ID'
Expand Down
7 changes: 5 additions & 2 deletions gcloud/pubsub/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ class Connection(base_connection.JSONConnection):
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(PUBSUB_EMULATOR,
self.__class__.API_BASE_URL)
emulator_host = os.getenv(PUBSUB_EMULATOR)
if emulator_host is None:
api_base_url = self.__class__.API_BASE_URL
else:
api_base_url = 'http://' + emulator_host

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

self.api_base_url = api_base_url

def build_api_url(self, path, query_params=None,
Expand Down
4 changes: 2 additions & 2 deletions gcloud/pubsub/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ def test_custom_url_from_env(self):
from gcloud._testing import _Monkey
from gcloud.environment_vars import PUBSUB_EMULATOR

HOST = object()
HOST = 'localhost:8187'
fake_environ = {PUBSUB_EMULATOR: HOST}

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

klass = self._getTargetClass()
self.assertNotEqual(conn.api_base_url, klass.API_BASE_URL)
self.assertEqual(conn.api_base_url, HOST)
self.assertEqual(conn.api_base_url, 'http://' + HOST)

def test_custom_url_from_constructor(self):
HOST = object()
Expand Down