@@ -40,35 +40,41 @@ def test_read_only_transaction(self):
4040 connect_args = {"client" : self .client , "pool" : FixedSizePool (size = 10 )},
4141 )
4242
43- with Session (engine .execution_options (read_only = True )) as session :
44- # Execute two queries in a read-only transaction.
45- session .scalars (select (Singer )).all ()
46- session .scalars (select (Singer )).all ()
43+ for i in range (2 ):
44+ with Session (engine .execution_options (read_only = True )) as session :
45+ # Execute two queries in a read-only transaction.
46+ session .scalars (select (Singer )).all ()
47+ session .scalars (select (Singer )).all ()
4748
4849 # Verify the requests that we got.
4950 requests = self .spanner_service .requests
50- eq_ (5 , len (requests ))
51+ eq_ (9 , len (requests ))
5152 is_instance_of (requests [0 ], BatchCreateSessionsRequest )
5253 # We should get rid of this extra round-trip for GetSession....
5354 is_instance_of (requests [1 ], GetSessionRequest )
5455 is_instance_of (requests [2 ], BeginTransactionRequest )
5556 is_instance_of (requests [3 ], ExecuteSqlRequest )
5657 is_instance_of (requests [4 ], ExecuteSqlRequest )
58+ is_instance_of (requests [5 ], GetSessionRequest )
59+ is_instance_of (requests [6 ], BeginTransactionRequest )
60+ is_instance_of (requests [7 ], ExecuteSqlRequest )
61+ is_instance_of (requests [8 ], ExecuteSqlRequest )
5762 # Verify that the transaction is a read-only transaction.
58- begin_request : BeginTransactionRequest = requests [2 ]
59- eq_ (
60- TransactionOptions (
61- dict (
62- read_only = TransactionOptions .ReadOnly (
63- dict (
64- strong = True ,
65- return_read_timestamp = True ,
63+ for index in [2 , 6 ]:
64+ begin_request : BeginTransactionRequest = requests [index ]
65+ eq_ (
66+ TransactionOptions (
67+ dict (
68+ read_only = TransactionOptions .ReadOnly (
69+ dict (
70+ strong = True ,
71+ return_read_timestamp = True ,
72+ )
6673 )
6774 )
68- )
69- ),
70- begin_request .options ,
71- )
75+ ),
76+ begin_request .options ,
77+ )
7278
7379
7480def add_singer_query_result (sql : str ):
0 commit comments