Skip to content

Commit 75d22ad

Browse files
committed
Removing dataset_id from allocate_ids.
It can be implied from the incomplete_key passed in.
1 parent 77cfe10 commit 75d22ad

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

gcloud/datastore/__init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def get_entities(keys, missing=None, deferred=None,
205205
return entities
206206

207207

208-
def allocate_ids(incomplete_key, num_ids, connection=None, dataset_id=None):
208+
def allocate_ids(incomplete_key, num_ids, connection=None):
209209
"""Allocates a list of IDs from a partial key.
210210
211211
:type incomplete_key: A :class:`gcloud.datastore.key.Key`
@@ -217,23 +217,20 @@ def allocate_ids(incomplete_key, num_ids, connection=None, dataset_id=None):
217217
:type connection: :class:`gcloud.datastore.connection.Connection`
218218
:param connection: Optional. The connection used to connect to datastore.
219219
220-
:type dataset_id: string
221-
:param dataset_id: Optional. The ID of the dataset.
222-
223220
:rtype: list of :class:`gcloud.datastore.key.Key`
224221
:returns: The (complete) keys allocated with ``incomplete_key`` as root.
225222
:raises: :class:`ValueError` if ``incomplete_key`` is not a partial key.
226223
"""
227224
connection = _require_connection(connection)
228-
dataset_id = _require_dataset_id(dataset_id)
229225

230226
if not incomplete_key.is_partial:
231227
raise ValueError(('Key is not partial.', incomplete_key))
232228

233229
incomplete_key_pb = incomplete_key.to_protobuf()
234230
incomplete_key_pbs = [incomplete_key_pb] * num_ids
235231

236-
allocated_key_pbs = connection.allocate_ids(dataset_id, incomplete_key_pbs)
232+
allocated_key_pbs = connection.allocate_ids(incomplete_key.dataset_id,
233+
incomplete_key_pbs)
237234
allocated_ids = [allocated_key_pb.path_element[-1].id
238235
for allocated_key_pb in allocated_key_pbs]
239236
return [incomplete_key.completed_key(allocated_id)

gcloud/datastore/test___init__.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -358,11 +358,9 @@ def test_get_entities_implicit(self):
358358

359359
class Test_allocate_ids_function(unittest2.TestCase):
360360

361-
def _callFUT(self, incomplete_key, num_ids,
362-
connection=None, dataset_id=None):
361+
def _callFUT(self, incomplete_key, num_ids, connection=None):
363362
from gcloud.datastore import allocate_ids
364-
return allocate_ids(incomplete_key, num_ids, connection=connection,
365-
dataset_id=dataset_id)
363+
return allocate_ids(incomplete_key, num_ids, connection=connection)
366364

367365
def test_allocate_ids(self):
368366
from gcloud.datastore.key import Key
@@ -372,8 +370,7 @@ def test_allocate_ids(self):
372370
INCOMPLETE_KEY = Key('KIND', dataset_id=DATASET_ID)
373371
CONNECTION = _Connection()
374372
NUM_IDS = 2
375-
result = self._callFUT(INCOMPLETE_KEY, NUM_IDS,
376-
connection=CONNECTION, dataset_id=DATASET_ID)
373+
result = self._callFUT(INCOMPLETE_KEY, NUM_IDS, connection=CONNECTION)
377374

378375
# Check the IDs returned match.
379376
self.assertEqual([key.id for key in result], range(NUM_IDS))

0 commit comments

Comments
 (0)