@@ -218,53 +218,15 @@ class Foo(Exception):
218218 self .assertIsNone (xact .id )
219219 self .assertEqual (ds_api .begin_transaction .call_count , 1 )
220220
221- def test_default (self ):
222- project = 'PROJECT'
223- id_ = 850302
224- ds_api = _make_datastore_api (xact = id_ )
225- client = _Client (project , datastore_api = ds_api )
226- xact = self ._make_one (client )
227- self .assertTrue (isinstance (xact .options , self ._get_options_class ()))
228-
229- def test_read_only (self ):
221+ def test_constructor_read_only (self ):
230222 project = 'PROJECT'
231223 id_ = 850302
232224 ds_api = _make_datastore_api (xact = id_ )
233225 client = _Client (project , datastore_api = ds_api )
234226 read_only = self ._get_options_class ().ReadOnly ()
235227 options = self ._make_options (read_only = read_only )
236228 xact = self ._make_one (client , read_only = True )
237- xact .begin ()
238- begin = ds_api .begin_transaction
239- begin .assert_called_once ()
240- self .assertEqual (begin .call_count , 1 )
241-
242- def test_read_write (self ):
243- project = 'PROJECT'
244- id_ = 850304
245- ds_api = _make_datastore_api (xact_id = id_ )
246- client = _Client (project , datastore_api = ds_api )
247- options = self ._make_options (read_write =
248- self ._get_options_class ().ReadWrite ())
249- xact = self ._make_one (client )
250- xact .begin ()
251- begin = ds_api .begin_transaction
252- begin .assert_called_once ()
253- self .assertEqual (begin .call_count , 1 )
254-
255- def test_previous_tid (self ):
256- project = 'PROJECT'
257- id_ = 943243
258- ds_api = _make_datastore_api (xact_id = id_ )
259- client = _Client (project , datastore_api = ds_api )
260- options_klass = self ._get_options_class ()
261- read_write = options_klass .ReadWrite (previous_transaction = b'321' )
262- options = self ._make_options (read_write = read_write )
263- xact = self ._make_one (client )
264- xact .begin ()
265- begin = ds_api .begin_transaction
266- begin .assert_called_once ()
267- self .assertEqual (begin .call_count , 1 )
229+ self .assertEqual (xact ._options , options )
268230
269231 def test_put_read_only (self ):
270232 project = 'PROJECT'
@@ -279,34 +241,6 @@ def test_put_read_only(self):
279241 with self .assertRaises (RuntimeError ):
280242 xact .put (entity )
281243
282- def test_put_read_write (self ):
283- project = 'PROJECT'
284- id_ = 943243
285- ds_api = _make_datastore_api (xact_id = id_ )
286- client = _Client (project , datastore_api = ds_api )
287- options_klass = self ._get_options_class ()
288- read_write = options_klass .ReadWrite (previous_transaction = b'321' )
289- options = self ._make_options (read_write = read_write )
290- entity = _Entity ()
291- xact = self ._make_one (client )
292- xact .begin ()
293- xact .put (entity )
294- mutated_entity = _mutated_pb (self , xact .mutations , 'insert' )
295- self .assertEqual (mutated_entity .key , entity .key .to_protobuf ())
296-
297-
298- def _mutated_pb (test_case , mutation_pb_list , mutation_type ):
299- # Make sure there is only one mutation.
300- test_case .assertEqual (len (mutation_pb_list ), 1 )
301-
302- # We grab the only mutation.
303- mutated_pb = mutation_pb_list [0 ]
304- # Then check if it is the correct type.
305- test_case .assertEqual (mutated_pb .WhichOneof ('operation' ),
306- mutation_type )
307-
308- return getattr (mutated_pb , mutation_type )
309-
310244
311245def _make_key (kind , id_ , project ):
312246 from google .cloud .datastore_v1 .proto import entity_pb2
0 commit comments