1717import unittest2
1818
1919from gcloud import datastore
20- from gcloud .datastore import _implicit_environ
20+ from gcloud .datastore import client
2121# This assumes the command is being run via tox hence the
2222# repository root is the current directory.
2323from system_tests import populate_datastore
2424
2525
26- _implicit_environ ._DATASET_ENV_VAR_NAME = 'GCLOUD_TESTS_DATASET_ID'
26+ client ._DATASET_ENV_VAR_NAME = 'GCLOUD_TESTS_DATASET_ID'
2727client = datastore .Client ()
2828
2929
@@ -56,7 +56,7 @@ def test_allocate_ids(self):
5656
5757class TestDatastoreSave (TestDatastore ):
5858
59- PARENT = datastore . Key ('Blog' , 'PizzaMan' )
59+ PARENT = client . key ('Blog' , 'PizzaMan' )
6060
6161 def _get_post (self , id_or_name = None , post_content = None ):
6262 post_content = post_content or {
@@ -71,7 +71,7 @@ def _get_post(self, id_or_name=None, post_content=None):
7171 # Create an entity with the given content.
7272 # NOTE: Using a parent to ensure consistency for query
7373 # in `test_empty_kind`.
74- key = datastore . Key ('Post' , parent = self .PARENT )
74+ key = client . key ('Post' , parent = self .PARENT )
7575 entity = datastore .Entity (key = key )
7676 entity .update (post_content )
7777
@@ -140,8 +140,8 @@ def test_empty_kind(self):
140140class TestDatastoreSaveKeys (TestDatastore ):
141141
142142 def test_save_key_self_reference (self ):
143- parent_key = datastore . Key ('Residence' , 'NewYork' )
144- key = datastore . Key ('Person' , 'name' , parent = parent_key )
143+ parent_key = client . key ('Residence' , 'NewYork' )
144+ key = client . key ('Person' , 'name' , parent = parent_key )
145145 entity = datastore .Entity (key = key )
146146 entity ['fullName' ] = u'Full name'
147147 entity ['linkedTo' ] = key # Self reference.
@@ -164,7 +164,7 @@ class TestDatastoreQuery(TestDatastore):
164164 def setUpClass (cls ):
165165 super (TestDatastoreQuery , cls ).setUpClass ()
166166 cls .CHARACTERS = populate_datastore .CHARACTERS
167- cls .ANCESTOR_KEY = datastore . Key (* populate_datastore .ANCESTOR )
167+ cls .ANCESTOR_KEY = client . key (* populate_datastore .ANCESTOR )
168168
169169 def _base_query (self ):
170170 return client .query (kind = 'Character' , ancestor = self .ANCESTOR_KEY )
@@ -212,7 +212,7 @@ def test_ancestor_query(self):
212212 self .assertEqual (len (entities ), expected_matches )
213213
214214 def test_query___key___filter (self ):
215- rickard_key = datastore . Key (* populate_datastore .RICKARD )
215+ rickard_key = client . key (* populate_datastore .RICKARD )
216216
217217 query = self ._base_query ()
218218 query .add_filter ('__key__' , '=' , rickard_key )
@@ -327,7 +327,7 @@ def test_query_group_by(self):
327327class TestDatastoreTransaction (TestDatastore ):
328328
329329 def test_transaction (self ):
330- entity = datastore .Entity (key = datastore . Key ('Company' , 'Google' ))
330+ entity = datastore .Entity (key = client . key ('Company' , 'Google' ))
331331 entity ['url' ] = u'www.google.com'
332332
333333 with client .transaction () as xact :
0 commit comments