@@ -124,6 +124,69 @@ def _get_target_class():
124124 def _make_one (self , * args , ** kwargs ):
125125 return self ._get_target_class ()(* args , ** kwargs )
126126
127+ def test_lookup (self ):
128+ from google .cloud .gapic .datastore .v1 import datastore_client
129+
130+ patch1 = mock .patch .object (
131+ datastore_client .DatastoreClient , '__init__' ,
132+ return_value = None )
133+ patch2 = mock .patch .object (datastore_client .DatastoreClient , 'lookup' )
134+ patch3 = mock .patch (
135+ 'google.cloud.datastore._gax._grpc_catch_rendezvous' )
136+
137+ with patch1 as mock_constructor :
138+ ds_api = self ._make_one ()
139+ mock_constructor .assert_called_once_with ()
140+ with patch2 as mock_lookup :
141+ with patch3 as mock_catch_rendezvous :
142+ mock_catch_rendezvous .assert_not_called ()
143+ ds_api .lookup (None , True , bb = 'cc' )
144+ mock_lookup .assert_called_once_with (None , True , bb = 'cc' )
145+ mock_catch_rendezvous .assert_called_once_with ()
146+
147+ def test_run_query (self ):
148+ from google .cloud .gapic .datastore .v1 import datastore_client
149+
150+ patch1 = mock .patch .object (
151+ datastore_client .DatastoreClient , '__init__' ,
152+ return_value = None )
153+ patch2 = mock .patch .object (
154+ datastore_client .DatastoreClient , 'run_query' )
155+ patch3 = mock .patch (
156+ 'google.cloud.datastore._gax._grpc_catch_rendezvous' )
157+
158+ with patch1 as mock_constructor :
159+ ds_api = self ._make_one ()
160+ mock_constructor .assert_called_once_with ()
161+ with patch2 as mock_run_query :
162+ with patch3 as mock_catch_rendezvous :
163+ mock_catch_rendezvous .assert_not_called ()
164+ ds_api .run_query ('47a' , none = None )
165+ mock_run_query .assert_called_once_with ('47a' , none = None )
166+ mock_catch_rendezvous .assert_called_once_with ()
167+
168+ def test_begin_transaction (self ):
169+ from google .cloud .gapic .datastore .v1 import datastore_client
170+
171+ patch1 = mock .patch .object (
172+ datastore_client .DatastoreClient , '__init__' ,
173+ return_value = None )
174+ patch2 = mock .patch .object (
175+ datastore_client .DatastoreClient , 'begin_transaction' )
176+ patch3 = mock .patch (
177+ 'google.cloud.datastore._gax._grpc_catch_rendezvous' )
178+
179+ with patch1 as mock_constructor :
180+ ds_api = self ._make_one ()
181+ mock_constructor .assert_called_once_with ()
182+ with patch2 as mock_begin_transaction :
183+ with patch3 as mock_catch_rendezvous :
184+ mock_catch_rendezvous .assert_not_called ()
185+ ds_api .begin_transaction ('a' , 'b' , [], key = 'kei' )
186+ mock_begin_transaction .assert_called_once_with (
187+ 'a' , 'b' , [], key = 'kei' )
188+ mock_catch_rendezvous .assert_called_once_with ()
189+
127190 def test_commit (self ):
128191 from google .cloud .gapic .datastore .v1 import datastore_client
129192
@@ -144,6 +207,50 @@ def test_commit(self):
144207 mock_commit .assert_called_once_with (1 , 2 , a = 3 )
145208 mock_catch_rendezvous .assert_called_once_with ()
146209
210+ def test_rollback (self ):
211+ from google .cloud .gapic .datastore .v1 import datastore_client
212+
213+ patch1 = mock .patch .object (
214+ datastore_client .DatastoreClient , '__init__' ,
215+ return_value = None )
216+ patch2 = mock .patch .object (
217+ datastore_client .DatastoreClient , 'rollback' )
218+ patch3 = mock .patch (
219+ 'google.cloud.datastore._gax._grpc_catch_rendezvous' )
220+
221+ with patch1 as mock_constructor :
222+ ds_api = self ._make_one ()
223+ mock_constructor .assert_called_once_with ()
224+ with patch2 as mock_rollback :
225+ with patch3 as mock_catch_rendezvous :
226+ mock_catch_rendezvous .assert_not_called ()
227+ ds_api .rollback (11 , 12 , arp = 'marp' )
228+ mock_rollback .assert_called_once_with (11 , 12 , arp = 'marp' )
229+ mock_catch_rendezvous .assert_called_once_with ()
230+
231+ def test_allocate_ids (self ):
232+ from google .cloud .gapic .datastore .v1 import datastore_client
233+
234+ patch1 = mock .patch .object (
235+ datastore_client .DatastoreClient , '__init__' ,
236+ return_value = None )
237+ patch2 = mock .patch .object (
238+ datastore_client .DatastoreClient , 'allocate_ids' )
239+ patch3 = mock .patch (
240+ 'google.cloud.datastore._gax._grpc_catch_rendezvous' )
241+
242+ with patch1 as mock_constructor :
243+ ds_api = self ._make_one ()
244+ mock_constructor .assert_called_once_with ()
245+ with patch2 as mock_allocate_ids :
246+ with patch3 as mock_catch_rendezvous :
247+ mock_catch_rendezvous .assert_not_called ()
248+ ds_api .allocate_ids (
249+ 'hey' , 'bai' , bye = (47 , 4 ), shy = {'a' : 4 })
250+ mock_allocate_ids .assert_called_once_with (
251+ 'hey' , 'bai' , bye = (47 , 4 ), shy = {'a' : 4 })
252+ mock_catch_rendezvous .assert_called_once_with ()
253+
147254
148255@unittest .skipUnless (_HAVE_GRPC , 'No gRPC' )
149256class Test_make_datastore_api (unittest .TestCase ):
0 commit comments