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