From 3cbfe2fbe7b87aaa6611789eda88d9c3a99cbb41 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 29 Apr 2015 16:08:41 -0400 Subject: [PATCH 1/2] Rename 'get_environ' -> 'check_environ'. Only caller ignored return value, so drop it. --- regression/regression_utils.py | 7 +------ regression/run_regression.py | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/regression/regression_utils.py b/regression/regression_utils.py index 5e4605fa006e..3ac52dc4ce4e 100644 --- a/regression/regression_utils.py +++ b/regression/regression_utils.py @@ -28,7 +28,7 @@ """ -def get_environ(require_datastore=False, require_storage=False): +def check_environ(require_datastore=False, require_storage=False): if require_datastore: if DATASET_ID is None or not os.path.isfile(CREDENTIALS): print(ENVIRON_ERROR_MSG, file=sys.stderr) @@ -38,8 +38,3 @@ def get_environ(require_datastore=False, require_storage=False): if PROJECT_ID is None or not os.path.isfile(CREDENTIALS): print(ENVIRON_ERROR_MSG, file=sys.stderr) sys.exit(1) - - return { - 'project_id': PROJECT_ID, - 'dataset_id': DATASET_ID, - } diff --git a/regression/run_regression.py b/regression/run_regression.py index 67666d817e0d..9a1545056a0b 100644 --- a/regression/run_regression.py +++ b/regression/run_regression.py @@ -42,9 +42,9 @@ def main(): args = parser.parse_args() # Make sure environ is set before running test. if args.package == 'datastore': - regression_utils.get_environ(require_datastore=True) + regression_utils.check_environ(require_datastore=True) elif args.package == 'storage': - regression_utils.get_environ(require_storage=True) + regression_utils.check_environ(require_storage=True) test_result = run_module_tests(args.package) if not test_result.wasSuccessful(): sys.exit(1) From bede80fa8079baed2585a088729c7bf925a39681 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Wed, 29 Apr 2015 16:09:20 -0400 Subject: [PATCH 2/2] Consistency: use 'project' everywhere, rather than 'project_id'. --- docs/pubsub-usage.rst | 6 +++--- gcloud/test__helpers.py | 6 +++--- regression/pubsub.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/pubsub-usage.rst b/docs/pubsub-usage.rst index cbe8e164f605..795a64d9464b 100644 --- a/docs/pubsub-usage.rst +++ b/docs/pubsub-usage.rst @@ -8,7 +8,7 @@ Connection / Authorization - credentials (derived from GAE / GCE environ if present). - - ``project_id`` (derived from GAE / GCE environ if present). + - ``project`` (derived from GAE / GCE environ if present). - ``scopes`` @@ -29,7 +29,7 @@ Create a new topic for an explicit project: .. doctest:: >>> from gcloud.pubsub import Topic - >>> topic = Topic('topic_name', project_id='my.project') + >>> topic = Topic('topic_name', project='my.project') >>> topic.create() # API request Check for the existance of a topic: @@ -54,7 +54,7 @@ List topics for an explicit project: .. doctest:: >>> from gcloud.pubsub import list_topics - >>> topics = list_topics(project_id='my.project') # API request + >>> topics = list_topics(project='my.project') # API request >>> [topic.name for topic in topics] ['topic_name'] diff --git a/gcloud/test__helpers.py b/gcloud/test__helpers.py index a543e3245f73..21cfadd433ba 100644 --- a/gcloud/test__helpers.py +++ b/gcloud/test__helpers.py @@ -340,13 +340,13 @@ def close(self): class _HTTPConnection(_BaseHTTPConnection): - def __init__(self, status, project_id): + def __init__(self, status, project): super(_HTTPConnection, self).__init__() self.status = status - self.project_id = project_id + self.project = project def getresponse(self): - return _HTTPResponse(self.status, self.project_id) + return _HTTPResponse(self.status, self.project) class _TimeoutHTTPConnection(_BaseHTTPConnection): diff --git a/regression/pubsub.py b/regression/pubsub.py index 7c0db3cffc6e..2c86148ac4da 100644 --- a/regression/pubsub.py +++ b/regression/pubsub.py @@ -57,10 +57,10 @@ def test_list_topics(self): # Retrieve the topics. all_topics, _ = pubsub.list_topics() - project_id = pubsub.get_default_project() + project = pubsub.get_default_project() created = [topic for topic in all_topics if topic.name in topics_to_create and - topic.project == project_id] + topic.project == project] self.assertEqual(len(created), len(topics_to_create)) def test_create_subscription(self):