#NEWLINE# def test_commit_wo_transaction( self ) : #NEWLINE# #INDENT# from gcloud._testing import _Monkey #NEWLINE# from gcloud.datastore._generated import datastore_pb2 #NEWLINE# from gcloud.datastore import connection as MUT #NEWLINE# from gcloud.datastore.helpers import _new_value_pb #NEWLINE# PROJECT = 'PROJECT' #NEWLINE# key_pb = self . _make_key_pb ( PROJECT ) #NEWLINE# rsp_pb = datastore_pb2 . CommitResponse ( ) #NEWLINE# req_pb = datastore_pb2 . CommitRequest ( ) #NEWLINE# mutation = req_pb . mutations . add ( ) #NEWLINE# insert = mutation . upsert #NEWLINE# insert . key . CopyFrom ( cw ) #NEWLINE# value_pb = _new_value_pb ( insert , 'foo' ) #NEWLINE# value_pb . string_value = 'Foo' #NEWLINE# conn = self . _makeOne ( ) #NEWLINE# URI = '/' . join ( [ conn . api_base_url , conn . API_VERSION , 'projects' , ( PROJECT + ':commit' ) ] ) #NEWLINE# http = conn . _http = Http ( { #NEWLINE# #INDENT# 'status' : '200' , #NEWLINE# #UNINDENT# } , rsp_pb . SerializeToString ( ) ) #NEWLINE# expected_result = object ( ) #NEWLINE# _parsed = [ ] #NEWLINE# def mock_parse( response ) : #NEWLINE# #INDENT# _parsed . append ( response ) #NEWLINE# return expected_result #NEWLINE# #UNINDENT# with _Monkey ( MUT , _parse_commit_response = mock_parse ) : #NEWLINE# #INDENT# result = conn . commit ( PROJECT , req_pb , None ) #NEWLINE# #UNINDENT# self . assertTrue ( ( result is expected_result ) ) #NEWLINE# cw = http . _called_with #NEWLINE# self . _verifyProtobufCall ( cw , URI , conn ) #NEWLINE# rq_class = datastore_pb2 . CommitRequest #NEWLINE# request = rq_class ( ) #NEWLINE# request . ParseFromString ( cw [ 'body' ] ) #NEWLINE# self . assertEqual ( request . transaction , b'' ) #NEWLINE# self . assertEqual ( list ( request . mutations ) , [ mutation ] ) #NEWLINE# self . assertEqual ( request . mode , rq_class . NON_TRANSACTIONAL ) #NEWLINE# self . assertEqual ( _parsed , [ rsp_pb ] )