diff --git a/gcloud/datastore/__init__.py b/gcloud/datastore/__init__.py index 757aaafe50aa..b1c98be07b5f 100644 --- a/gcloud/datastore/__init__.py +++ b/gcloud/datastore/__init__.py @@ -55,7 +55,7 @@ from gcloud import credentials from gcloud.datastore import _implicit_environ from gcloud.datastore.api import allocate_ids -from gcloud.datastore.api import get_entities +from gcloud.datastore.api import get from gcloud.datastore.connection import Connection diff --git a/gcloud/datastore/api.py b/gcloud/datastore/api.py index 946e45a51414..7c0e893e160a 100644 --- a/gcloud/datastore/api.py +++ b/gcloud/datastore/api.py @@ -58,7 +58,7 @@ def _require_connection(connection=None): return connection -def get_entities(keys, missing=None, deferred=None, connection=None): +def get(keys, missing=None, deferred=None, connection=None): """Retrieves entities, along with their attributes. :type keys: list of :class:`gcloud.datastore.key.Key` @@ -92,8 +92,7 @@ def get_entities(keys, missing=None, deferred=None, connection=None): # or if we made sure that a prefix s~ or e~ was on each key. for key in keys[1:]: if key.dataset_id != dataset_id: - raise ValueError('All keys in get_entities must be from the ' - 'same dataset.') + raise ValueError('All keys in get must be from the same dataset.') entity_pbs = connection.lookup( dataset_id=dataset_id, diff --git a/gcloud/datastore/demo/demo.py b/gcloud/datastore/demo/demo.py index bc611c806a78..ce653ebfd852 100644 --- a/gcloud/datastore/demo/demo.py +++ b/gcloud/datastore/demo/demo.py @@ -30,14 +30,14 @@ toy.save() # If we look it up by its key, we should find it... -from gcloud.datastore import get_entities -print(get_entities([toy.key])) +from gcloud.datastore import get +print(get([toy.key])) # And we should be able to delete it... toy.key.delete() # Since we deleted it, if we do another lookup it shouldn't be there again: -print(get_entities([toy.key])) +print(get([toy.key])) # Now let's try a more advanced query. # First, let's create some entities. @@ -104,7 +104,7 @@ t.rollback() # Let's check if the entity was actually created: -created = get_entities([key]) +created = get([key]) print('yes' if created else 'no') # Remember, a key won't be complete until the transaction is commited. diff --git a/gcloud/datastore/key.py b/gcloud/datastore/key.py index cfa7d03f1eeb..17583678514a 100644 --- a/gcloud/datastore/key.py +++ b/gcloud/datastore/key.py @@ -232,7 +232,7 @@ def get(self, connection=None): # We allow partial keys to attempt a get, the backend will fail. connection = connection or _implicit_environ.CONNECTION - entities = api.get_entities([self], connection=connection) + entities = api.get([self], connection=connection) if entities: result = entities[0] diff --git a/gcloud/datastore/test_api.py b/gcloud/datastore/test_api.py index 92bfce9be222..1e66b07de181 100644 --- a/gcloud/datastore/test_api.py +++ b/gcloud/datastore/test_api.py @@ -90,18 +90,18 @@ def test__require_connection_implicit_set_passed_explicitly(self): self.assertTrue(self._callFUT(CONNECTION) is CONNECTION) -class Test_get_entities_function(unittest2.TestCase): +class Test_get_function(unittest2.TestCase): def _callFUT(self, keys, missing=None, deferred=None, connection=None): - from gcloud.datastore import get_entities - return get_entities(keys, missing=missing, deferred=deferred, - connection=connection) + from gcloud.datastore.api import get + return get(keys, missing=missing, deferred=deferred, + connection=connection) - def test_get_entities_no_keys(self): + def test_get_no_keys(self): results = self._callFUT([]) self.assertEqual(results, []) - def test_get_entities_miss(self): + def test_get_miss(self): from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -111,7 +111,7 @@ def test_get_entities_miss(self): results = self._callFUT([key], connection=connection) self.assertEqual(results, []) - def test_get_entities_miss_w_missing(self): + def test_get_miss_w_missing(self): from gcloud.datastore import datastore_v1_pb2 as datastore_pb from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -138,7 +138,7 @@ def test_get_entities_miss_w_missing(self): self.assertEqual([missed.key.to_protobuf() for missed in missing], [key.to_protobuf()]) - def test_get_entities_miss_w_deferred(self): + def test_get_miss_w_deferred(self): from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -172,7 +172,7 @@ def _make_entity_pb(self, dataset_id, kind, integer_id, return entity_pb - def test_get_entities_hit(self): + def test_get_hit(self): from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -199,7 +199,7 @@ def test_get_entities_hit(self): self.assertEqual(list(result), ['foo']) self.assertEqual(result['foo'], 'Foo') - def test_get_entities_hit_multiple_keys_same_dataset(self): + def test_get_hit_multiple_keys_same_dataset(self): from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -226,7 +226,7 @@ def test_get_entities_hit_multiple_keys_same_dataset(self): self.assertEqual(retrieved2.key.path, key2.path) self.assertEqual(dict(retrieved2), {}) - def test_get_entities_hit_multiple_keys_different_dataset(self): + def test_get_hit_multiple_keys_different_dataset(self): from gcloud.datastore.key import Key DATASET_ID1 = 'DATASET' @@ -240,7 +240,7 @@ def test_get_entities_hit_multiple_keys_different_dataset(self): with self.assertRaises(ValueError): self._callFUT([key1, key2], connection=object()) - def test_get_entities_implicit(self): + def test_get_implicit(self): from gcloud.datastore import _implicit_environ from gcloud.datastore.key import Key from gcloud.datastore.test_connection import _Connection @@ -281,7 +281,7 @@ def test_get_entities_implicit(self): class Test_allocate_ids_function(unittest2.TestCase): def _callFUT(self, incomplete_key, num_ids, connection=None): - from gcloud.datastore import allocate_ids + from gcloud.datastore.api import allocate_ids return allocate_ids(incomplete_key, num_ids, connection=connection) def test_allocate_ids(self): diff --git a/regression/datastore.py b/regression/datastore.py index 78b5597125ca..1931aa63ce4b 100644 --- a/regression/datastore.py +++ b/regression/datastore.py @@ -131,7 +131,7 @@ def test_save_multiple(self): self.case_entities_to_delete.append(entity2) keys = [entity1.key, entity2.key] - matches = datastore.get_entities(keys) + matches = datastore.get(keys) self.assertEqual(len(matches), 2) def test_empty_kind(self):