44
55import pytest
66from pymongo .errors import OperationFailure , InvalidOperation
7+ from pymongo .read_concern import ReadConcern
78
89from mongoengine import *
910from mongoengine .asynchronous import async_register_connection , async_get_db , async_connect
@@ -367,8 +368,6 @@ async def test_updating_a_document_within_a_transaction_that_fails(self):
367368 class A (Document ):
368369 name = StringField ()
369370
370- await A .adrop_collection ()
371-
372371 a_doc = await A .aobjects .create (name = "a" )
373372
374373 with pytest .raises (TestRollbackError ):
@@ -385,8 +384,6 @@ async def test_creating_a_document_within_a_transaction(self):
385384 class A (Document ):
386385 name = StringField ()
387386
388- await A .adrop_collection ()
389-
390387 # ensure the collection is created (needed for transaction with MongoDB <= 4.2)
391388 await A .aobjects .create (name = "test" )
392389 await A .aobjects .delete ()
@@ -407,7 +404,6 @@ async def test_creating_a_document_within_a_transaction_that_fails(self):
407404 class A (Document ):
408405 name = StringField ()
409406
410- await A .adrop_collection ()
411407 # ensure a collection is created (needed for transaction with MongoDB <= 4.2)
412408 await A .aobjects .create (name = "test" )
413409 await A .aobjects .delete ()
@@ -455,19 +451,15 @@ async def test_collection_creation_via_upserts_across_databases_in_transaction(s
455451 class A (Document ):
456452 name = StringField ()
457453
458- await A .adrop_collection ()
459-
460454 a_doc = await A .aobjects .create (name = "a" )
461455
462456 class B (Document ):
463457 meta = {"db_alias" : "test2" }
464458 name = StringField ()
465459
466- await B .adrop_collection ()
467-
468460 b_doc = await B .aobjects .create (name = "b" )
469461
470- async with run_in_transaction ():
462+ async with run_in_transaction (transaction_kwargs = { "read_concern" : ReadConcern ( "local" )} ):
471463 await a_doc .aupdate (name = "a3" )
472464 with switch_db (A , "test2" ):
473465 await a_doc .aupdate (name = "a4" , upsert = True )
0 commit comments