30
30
)
31
31
from test .utils_spec_runner import SpecRunner
32
32
33
+ from bson import encode
34
+ from bson .raw_bson import RawBSONDocument
33
35
from gridfs import GridFS , GridFSBucket
34
36
from pymongo import WriteConcern , client_session
35
37
from pymongo .client_session import TransactionOptions
@@ -330,14 +332,14 @@ def test_transaction_starts_with_batched_write(self):
330
332
listener .reset ()
331
333
self .addCleanup (client .close )
332
334
self .addCleanup (coll .drop )
333
- large_str = "\0 " * (10 * 1024 * 1024 )
334
- ops = [InsertOne ({"a" : large_str }) for _ in range (10 )]
335
+ large_str = "\0 " * (1 * 1024 * 1024 )
336
+ ops = [InsertOne (RawBSONDocument ( encode ( {"a" : large_str }))) for _ in range (48 )]
335
337
with client .start_session () as session :
336
338
with session .start_transaction ():
337
339
coll .bulk_write (ops , session = session )
338
340
# Assert commands were constructed properly.
339
341
self .assertEqual (
340
- ["insert" , "insert" , "insert" , " commitTransaction" ], listener .started_command_names ()
342
+ ["insert" , "insert" , "commitTransaction" ], listener .started_command_names ()
341
343
)
342
344
first_cmd = listener .results ["started" ][0 ].command
343
345
self .assertTrue (first_cmd ["startTransaction" ])
@@ -347,7 +349,7 @@ def test_transaction_starts_with_batched_write(self):
347
349
self .assertNotIn ("startTransaction" , event .command )
348
350
self .assertEqual (lsid , event .command ["lsid" ])
349
351
self .assertEqual (txn_number , event .command ["txnNumber" ])
350
- self .assertEqual (10 , coll .count_documents ({}))
352
+ self .assertEqual (48 , coll .count_documents ({}))
351
353
352
354
353
355
class PatchSessionTimeout (object ):
0 commit comments