@@ -672,25 +672,33 @@ def test_run_query_w_namespace_nonempty_result(self):
672672 def test_begin_transaction (self ):
673673 from google .cloud .proto .datastore .v1 import datastore_pb2
674674
675- PROJECT = 'PROJECT'
676- TRANSACTION = b'TRANSACTION'
675+ project = 'PROJECT'
676+ transaction = b'TRANSACTION'
677677 rsp_pb = datastore_pb2 .BeginTransactionResponse ()
678- rsp_pb .transaction = TRANSACTION
678+ rsp_pb .transaction = transaction
679+
680+ # Create mock HTTP and client with response.
679681 http = Http ({'status' : '200' }, rsp_pb .SerializeToString ())
680682 client = mock .Mock (_http = http , spec = ['_http' ])
683+
684+ # Make request.
681685 conn = self ._make_one (client )
682- URI = '/' .join ([
686+ response = conn .begin_transaction (project )
687+
688+ # Check the result and verify the callers.
689+ self .assertEqual (response , rsp_pb )
690+ uri = '/' .join ([
683691 conn .api_base_url ,
684692 conn .API_VERSION ,
685693 'projects' ,
686- PROJECT + ':beginTransaction' ,
694+ project + ':beginTransaction' ,
687695 ])
688- self .assertEqual (conn .begin_transaction (PROJECT ), TRANSACTION )
689696 cw = http ._called_with
690- self ._verify_protobuf_call (cw , URI , conn )
691- rq_class = datastore_pb2 .BeginTransactionRequest
692- request = rq_class ()
697+ self ._verify_protobuf_call (cw , uri , conn )
698+ request = datastore_pb2 .BeginTransactionRequest ()
693699 request .ParseFromString (cw ['body' ])
700+ # The RPC-over-HTTP request does not set the project in the request.
701+ self .assertEqual (request .project_id , u'' )
694702
695703 def test_commit_wo_transaction (self ):
696704 from google .cloud .proto .datastore .v1 import datastore_pb2
0 commit comments