Skip to content

Commit bc4bcc8

Browse files
committed
Renaming datastore.api.get_entities to get.
1 parent 2788bbd commit bc4bcc8

File tree

6 files changed

+22
-23
lines changed

6 files changed

+22
-23
lines changed

gcloud/datastore/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
from gcloud import credentials
5656
from gcloud.datastore import _implicit_environ
5757
from gcloud.datastore.api import allocate_ids
58-
from gcloud.datastore.api import get_entities
58+
from gcloud.datastore.api import get
5959
from gcloud.datastore.connection import Connection
6060

6161

gcloud/datastore/api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _require_connection(connection=None):
5858
return connection
5959

6060

61-
def get_entities(keys, missing=None, deferred=None, connection=None):
61+
def get(keys, missing=None, deferred=None, connection=None):
6262
"""Retrieves entities, along with their attributes.
6363
6464
:type keys: list of :class:`gcloud.datastore.key.Key`
@@ -92,8 +92,7 @@ def get_entities(keys, missing=None, deferred=None, connection=None):
9292
# or if we made sure that a prefix s~ or e~ was on each key.
9393
for key in keys[1:]:
9494
if key.dataset_id != dataset_id:
95-
raise ValueError('All keys in get_entities must be from the '
96-
'same dataset.')
95+
raise ValueError('All keys in get must be from the same dataset.')
9796

9897
entity_pbs = connection.lookup(
9998
dataset_id=dataset_id,

gcloud/datastore/demo/demo.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
toy.save()
3131

3232
# If we look it up by its key, we should find it...
33-
from gcloud.datastore import get_entities
34-
print(get_entities([toy.key]))
33+
from gcloud.datastore import get
34+
print(get([toy.key]))
3535

3636
# And we should be able to delete it...
3737
toy.key.delete()
3838

3939
# Since we deleted it, if we do another lookup it shouldn't be there again:
40-
print(get_entities([toy.key]))
40+
print(get([toy.key]))
4141

4242
# Now let's try a more advanced query.
4343
# First, let's create some entities.
@@ -104,7 +104,7 @@
104104
t.rollback()
105105

106106
# Let's check if the entity was actually created:
107-
created = get_entities([key])
107+
created = get([key])
108108
print('yes' if created else 'no')
109109

110110
# Remember, a key won't be complete until the transaction is commited.

gcloud/datastore/key.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ def get(self, connection=None):
232232

233233
# We allow partial keys to attempt a get, the backend will fail.
234234
connection = connection or _implicit_environ.CONNECTION
235-
entities = api.get_entities([self], connection=connection)
235+
entities = api.get([self], connection=connection)
236236

237237
if entities:
238238
result = entities[0]

gcloud/datastore/test_api.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ def test__require_connection_implicit_set_passed_explicitly(self):
9090
self.assertTrue(self._callFUT(CONNECTION) is CONNECTION)
9191

9292

93-
class Test_get_entities_function(unittest2.TestCase):
93+
class Test_get_function(unittest2.TestCase):
9494

9595
def _callFUT(self, keys, missing=None, deferred=None, connection=None):
96-
from gcloud.datastore import get_entities
97-
return get_entities(keys, missing=missing, deferred=deferred,
98-
connection=connection)
96+
from gcloud.datastore.api import get
97+
return get(keys, missing=missing, deferred=deferred,
98+
connection=connection)
9999

100-
def test_get_entities_no_keys(self):
100+
def test_get_no_keys(self):
101101
results = self._callFUT([])
102102
self.assertEqual(results, [])
103103

104-
def test_get_entities_miss(self):
104+
def test_get_miss(self):
105105
from gcloud.datastore.key import Key
106106
from gcloud.datastore.test_connection import _Connection
107107

@@ -111,7 +111,7 @@ def test_get_entities_miss(self):
111111
results = self._callFUT([key], connection=connection)
112112
self.assertEqual(results, [])
113113

114-
def test_get_entities_miss_w_missing(self):
114+
def test_get_miss_w_missing(self):
115115
from gcloud.datastore import datastore_v1_pb2 as datastore_pb
116116
from gcloud.datastore.key import Key
117117
from gcloud.datastore.test_connection import _Connection
@@ -138,7 +138,7 @@ def test_get_entities_miss_w_missing(self):
138138
self.assertEqual([missed.key.to_protobuf() for missed in missing],
139139
[key.to_protobuf()])
140140

141-
def test_get_entities_miss_w_deferred(self):
141+
def test_get_miss_w_deferred(self):
142142
from gcloud.datastore.key import Key
143143
from gcloud.datastore.test_connection import _Connection
144144

@@ -172,7 +172,7 @@ def _make_entity_pb(self, dataset_id, kind, integer_id,
172172

173173
return entity_pb
174174

175-
def test_get_entities_hit(self):
175+
def test_get_hit(self):
176176
from gcloud.datastore.key import Key
177177
from gcloud.datastore.test_connection import _Connection
178178

@@ -199,7 +199,7 @@ def test_get_entities_hit(self):
199199
self.assertEqual(list(result), ['foo'])
200200
self.assertEqual(result['foo'], 'Foo')
201201

202-
def test_get_entities_hit_multiple_keys_same_dataset(self):
202+
def test_get_hit_multiple_keys_same_dataset(self):
203203
from gcloud.datastore.key import Key
204204
from gcloud.datastore.test_connection import _Connection
205205

@@ -226,7 +226,7 @@ def test_get_entities_hit_multiple_keys_same_dataset(self):
226226
self.assertEqual(retrieved2.key.path, key2.path)
227227
self.assertEqual(dict(retrieved2), {})
228228

229-
def test_get_entities_hit_multiple_keys_different_dataset(self):
229+
def test_get_hit_multiple_keys_different_dataset(self):
230230
from gcloud.datastore.key import Key
231231

232232
DATASET_ID1 = 'DATASET'
@@ -240,7 +240,7 @@ def test_get_entities_hit_multiple_keys_different_dataset(self):
240240
with self.assertRaises(ValueError):
241241
self._callFUT([key1, key2], connection=object())
242242

243-
def test_get_entities_implicit(self):
243+
def test_get_implicit(self):
244244
from gcloud.datastore import _implicit_environ
245245
from gcloud.datastore.key import Key
246246
from gcloud.datastore.test_connection import _Connection
@@ -281,7 +281,7 @@ def test_get_entities_implicit(self):
281281
class Test_allocate_ids_function(unittest2.TestCase):
282282

283283
def _callFUT(self, incomplete_key, num_ids, connection=None):
284-
from gcloud.datastore import allocate_ids
284+
from gcloud.datastore.api import allocate_ids
285285
return allocate_ids(incomplete_key, num_ids, connection=connection)
286286

287287
def test_allocate_ids(self):

regression/datastore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def test_save_multiple(self):
131131
self.case_entities_to_delete.append(entity2)
132132

133133
keys = [entity1.key, entity2.key]
134-
matches = datastore.get_entities(keys)
134+
matches = datastore.get(keys)
135135
self.assertEqual(len(matches), 2)
136136

137137
def test_empty_kind(self):

0 commit comments

Comments
 (0)