Skip to content

Commit 8baf341

Browse files
committed
Valet service.
1 parent ce5a207 commit 8baf341

4 files changed

Lines changed: 17 additions & 25 deletions

File tree

gcloud/datastore/connection.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def begin_transaction(self, dataset_id, serializable=False):
315315
Maps the ``DatastoreService.BeginTransaction`` protobuf RPC.
316316
317317
:type dataset_id: string
318-
:param dataset_id: The ID dataset over which to execute the transaction.
318+
:param dataset_id: The ID dataset to which the transaction applies.
319319
"""
320320

321321
if self.transaction():
@@ -342,7 +342,7 @@ def commit(self, dataset_id, mutation_pb):
342342
Maps the ``DatastoreService.Commit`` protobuf RPC.
343343
344344
:type dataset_id: string
345-
:param dataset_id: The id of the dataset in which to perform the changes.
345+
:param dataset_id: The ID dataset to which the transaction applies.
346346
347347
:type mutation_pb: :class:`gcloud.datastore.datastore_v1_pb2.Mutation`.
348348
:param mutation_pb: The protobuf for the mutations being saved.

gcloud/datastore/key.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,7 @@ def parent(self):
370370
def __repr__(self):
371371
return '<Key%s, dataset=%s>' % (self.path, self.dataset_id)
372372

373+
373374
def _validate_dataset_id(dataset_id, parent):
374375
"""Ensure the dataset ID is set appropriately.
375376

gcloud/datastore/test___init__.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,32 +126,26 @@ def test_no_env_var_set(self):
126126
self.assertEqual(_implicit_environ.DATASET_ID, None)
127127

128128
def test_set_from_env_var(self):
129-
from gcloud.datastore import _DATASET_ENV_VAR_NAME
130129
from gcloud.datastore import _implicit_environ
131-
132-
# Make a custom getenv function to Monkey.
133-
DATASET = 'dataset'
134-
VALUES = {
135-
_DATASET_ENV_VAR_NAME: DATASET,
136-
}
137-
with self._monkey(DATASET):
130+
IMPLICIT_DATASET_ID = 'IMPLICIT'
131+
with self._monkey(IMPLICIT_DATASET_ID):
138132
self._callFUT()
139-
self.assertEqual(_implicit_environ.DATASET_ID, DATASET)
133+
self.assertEqual(_implicit_environ.DATASET_ID, IMPLICIT_DATASET_ID)
140134

141135
def test_set_explicit_w_env_var_set(self):
142136
from gcloud.datastore import _implicit_environ
143-
DATASET_ID = 'DATASET'
137+
EXPLICIT_DATASET_ID = 'EXPLICIT'
144138
with self._monkey(None):
145-
self._callFUT(DATASET_ID)
146-
self.assertEqual(_implicit_environ.DATASET_ID, DATASET_ID)
139+
self._callFUT(EXPLICIT_DATASET_ID)
140+
self.assertEqual(_implicit_environ.DATASET_ID, EXPLICIT_DATASET_ID)
147141

148142
def test_set_explicit_no_env_var_set(self):
149143
from gcloud.datastore import _implicit_environ
150144
IMPLICIT_DATASET_ID = 'IMPLICIT'
151-
DATASET_ID = 'DATASET'
145+
EXPLICIT_DATASET_ID = 'EXPLICIT'
152146
with self._monkey(IMPLICIT_DATASET_ID):
153-
self._callFUT(DATASET_ID)
154-
self.assertEqual(_implicit_environ.DATASET_ID, DATASET_ID)
147+
self._callFUT(EXPLICIT_DATASET_ID)
148+
self.assertEqual(_implicit_environ.DATASET_ID, EXPLICIT_DATASET_ID)
155149

156150
def test_set_explicit_None_wo_env_var_set(self):
157151
from gcloud.datastore import _implicit_environ

gcloud/datastore/test_key.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ def test_ctor_no_dataset_id(self):
5454
def test_ctor_w_implicit_dataset_id(self):
5555
_DATASET = 'DATASET'
5656
_KIND = 'KIND'
57-
klass = self._getTargetClass()
5857
with self._monkeyDatasetID(_DATASET):
5958
key = self._makeOne(_KIND)
6059
self.assertEqual(key.dataset_id, _DATASET)
@@ -64,13 +63,10 @@ def test_ctor_w_implicit_dataset_id(self):
6463

6564
def test_ctor_w_implicit_dataset_id_empty_path(self):
6665
_DATASET = 'DATASET'
67-
_KIND = 'KIND'
68-
klass = self._getTargetClass()
6966
with self._monkeyDatasetID(_DATASET):
7067
self.assertRaises(ValueError, self._makeOne)
7168

7269
def test_ctor_parent(self):
73-
_DATASET = 'DATASET'
7470
_PARENT_KIND = 'KIND1'
7571
_PARENT_ID = 1234
7672
_PARENT_DATASET = 'DATASET-ALT'
@@ -82,8 +78,8 @@ def test_ctor_parent(self):
8278
{'kind': _CHILD_KIND, 'id': _CHILD_ID},
8379
]
8480
parent_key = self._makeOne(_PARENT_KIND, _PARENT_ID,
85-
dataset_id=_PARENT_DATASET,
86-
namespace=_PARENT_NAMESPACE)
81+
dataset_id=_PARENT_DATASET,
82+
namespace=_PARENT_NAMESPACE)
8783
with self._monkeyDatasetID():
8884
key = self._makeOne(_CHILD_KIND, _CHILD_ID, parent=parent_key)
8985
self.assertEqual(key.dataset_id, parent_key.dataset_id)
@@ -107,7 +103,8 @@ def test_ctor_parent_bad_namespace(self):
107103
with self._monkeyDatasetID():
108104
parent_key = self._makeOne('KIND', 1234, namespace='FOO')
109105
with self.assertRaises(ValueError):
110-
self._makeOne('KIND2', 1234, namespace='BAR', parent=parent_key)
106+
self._makeOne(
107+
'KIND2', 1234, namespace='BAR', parent=parent_key)
111108

112109
def test_ctor_parent_bad_dataset_id(self):
113110
parent_key = self._makeOne('KIND', 1234, dataset_id='FOO')
@@ -178,7 +175,7 @@ def test_completed_key_on_partial_w_invalid(self):
178175
self.assertRaises(ValueError, key.completed_key, object())
179176

180177
def test_completed_key_on_complete(self):
181-
with self._monkeyDatasetID() as monkey:
178+
with self._monkeyDatasetID():
182179
key = self._makeOne('KIND', 1234)
183180
self.assertRaises(ValueError, key.completed_key, 5678)
184181

0 commit comments

Comments
 (0)