@@ -259,7 +259,12 @@ def test_commit_ok(self):
259259 "CloudSpanner.Commit" , attributes = dict (BASE_ATTRIBUTES , num_mutations = 1 )
260260 )
261261
262- def _test_commit_with_options (self , request_options = None , max_commit_delay_in = None ):
262+ def _test_commit_with_options (
263+ self ,
264+ request_options = None ,
265+ max_commit_delay_in = None ,
266+ exclude_txn_from_change_streams = False ,
267+ ):
263268 import datetime
264269 from google .cloud .spanner_v1 import CommitResponse
265270 from google .cloud .spanner_v1 import TransactionOptions
@@ -276,7 +281,9 @@ def _test_commit_with_options(self, request_options=None, max_commit_delay_in=No
276281 batch .transaction_tag = self .TRANSACTION_TAG
277282 batch .insert (TABLE_NAME , COLUMNS , VALUES )
278283 committed = batch .commit (
279- request_options = request_options , max_commit_delay = max_commit_delay_in
284+ request_options = request_options ,
285+ max_commit_delay = max_commit_delay_in ,
286+ exclude_txn_from_change_streams = exclude_txn_from_change_streams ,
280287 )
281288
282289 self .assertEqual (committed , now )
@@ -301,6 +308,10 @@ def _test_commit_with_options(self, request_options=None, max_commit_delay_in=No
301308 self .assertEqual (mutations , batch ._mutations )
302309 self .assertIsInstance (single_use_txn , TransactionOptions )
303310 self .assertTrue (type (single_use_txn ).pb (single_use_txn ).HasField ("read_write" ))
311+ self .assertEqual (
312+ single_use_txn .exclude_txn_from_change_streams ,
313+ exclude_txn_from_change_streams ,
314+ )
304315 self .assertEqual (
305316 metadata ,
306317 [
@@ -355,6 +366,14 @@ def test_commit_w_max_commit_delay(self):
355366 max_commit_delay_in = datetime .timedelta (milliseconds = 100 ),
356367 )
357368
369+ def test_commit_w_exclude_txn_from_change_streams (self ):
370+ request_options = RequestOptions (
371+ request_tag = "tag-1" ,
372+ )
373+ self ._test_commit_with_options (
374+ request_options = request_options , exclude_txn_from_change_streams = True
375+ )
376+
358377 def test_context_mgr_already_committed (self ):
359378 import datetime
360379 from google .cloud ._helpers import UTC
@@ -499,7 +518,9 @@ def test_batch_write_grpc_error(self):
499518 attributes = dict (BASE_ATTRIBUTES , num_mutation_groups = 1 ),
500519 )
501520
502- def _test_batch_write_with_request_options (self , request_options = None ):
521+ def _test_batch_write_with_request_options (
522+ self , request_options = None , exclude_txn_from_change_streams = False
523+ ):
503524 import datetime
504525 from google .cloud .spanner_v1 import BatchWriteResponse
505526 from google .cloud ._helpers import UTC
@@ -519,7 +540,10 @@ def _test_batch_write_with_request_options(self, request_options=None):
519540 group = groups .group ()
520541 group .insert (TABLE_NAME , COLUMNS , VALUES )
521542
522- response_iter = groups .batch_write (request_options )
543+ response_iter = groups .batch_write (
544+ request_options ,
545+ exclude_txn_from_change_streams = exclude_txn_from_change_streams ,
546+ )
523547 self .assertEqual (len (response_iter ), 1 )
524548 self .assertEqual (response_iter [0 ], response )
525549
@@ -528,6 +552,7 @@ def _test_batch_write_with_request_options(self, request_options=None):
528552 mutation_groups ,
529553 actual_request_options ,
530554 metadata ,
555+ request_exclude_txn_from_change_streams ,
531556 ) = api ._batch_request
532557 self .assertEqual (session , self .SESSION_NAME )
533558 self .assertEqual (mutation_groups , groups ._mutation_groups )
@@ -545,6 +570,9 @@ def _test_batch_write_with_request_options(self, request_options=None):
545570 else :
546571 expected_request_options = request_options
547572 self .assertEqual (actual_request_options , expected_request_options )
573+ self .assertEqual (
574+ request_exclude_txn_from_change_streams , exclude_txn_from_change_streams
575+ )
548576
549577 self .assertSpanAttributes (
550578 "CloudSpanner.BatchWrite" ,
@@ -567,6 +595,11 @@ def test_batch_write_w_incorrect_tag_dictionary_error(self):
567595 with self .assertRaises (ValueError ):
568596 self ._test_batch_write_with_request_options ({"incorrect_tag" : "tag-1-1" })
569597
598+ def test_batch_write_w_exclude_txn_from_change_streams (self ):
599+ self ._test_batch_write_with_request_options (
600+ exclude_txn_from_change_streams = True
601+ )
602+
570603
571604class _Session (object ):
572605 def __init__ (self , database = None , name = TestBatch .SESSION_NAME ):
@@ -625,6 +658,7 @@ def batch_write(
625658 request .mutation_groups ,
626659 request .request_options ,
627660 metadata ,
661+ request .exclude_txn_from_change_streams ,
628662 )
629663 if self ._rpc_error :
630664 raise Unknown ("error" )
0 commit comments