File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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
@@ -407,7 +408,6 @@ async def test_creating_a_document_within_a_transaction_that_fails(self):
407408 class A (Document ):
408409 name = StringField ()
409410
410- await A .adrop_collection ()
411411 # ensure a collection is created (needed for transaction with MongoDB <= 4.2)
412412 await A .aobjects .create (name = "test" )
413413 await A .aobjects .delete ()
@@ -455,19 +455,15 @@ async def test_collection_creation_via_upserts_across_databases_in_transaction(s
455455 class A (Document ):
456456 name = StringField ()
457457
458- await A .adrop_collection ()
459-
460458 a_doc = await A .aobjects .create (name = "a" )
461459
462460 class B (Document ):
463461 meta = {"db_alias" : "test2" }
464462 name = StringField ()
465463
466- await B .adrop_collection ()
467-
468464 b_doc = await B .aobjects .create (name = "b" )
469465
470- async with run_in_transaction ():
466+ async with run_in_transaction (transaction_kwargs = { "read_concern" : ReadConcern ( "local" )} ):
471467 await a_doc .aupdate (name = "a3" )
472468 with switch_db (A , "test2" ):
473469 await a_doc .aupdate (name = "a4" , upsert = True )
Original file line number Diff line number Diff line change 66
77import pytest
88from pymongo .errors import OperationFailure
9+ from pymongo .read_concern import ReadConcern
910
1011from mongoengine import *
1112from mongoengine .session import _get_session
@@ -436,7 +437,6 @@ def test_creating_a_document_within_a_transaction_that_fails(self):
436437 class A (Document ):
437438 name = StringField ()
438439
439- A .drop_collection ()
440440 # ensure a collection is created (needed for transaction with MongoDB <= 4.2)
441441 A .objects .create (name = "test" )
442442 A .objects .delete ()
@@ -484,19 +484,15 @@ def test_collection_creation_via_upserts_across_databases_in_transaction(self):
484484 class A (Document ):
485485 name = StringField ()
486486
487- A .drop_collection ()
488-
489487 a_doc = A .objects .create (name = "a" )
490488
491489 class B (Document ):
492490 meta = {"db_alias" : "test2" }
493491 name = StringField ()
494492
495- B .drop_collection ()
496-
497493 b_doc = B .objects .create (name = "b" )
498494
499- with run_in_transaction ():
495+ with run_in_transaction (transaction_kwargs = { "read_concern" : ReadConcern ( "local" )} ):
500496 a_doc .update (name = "a3" )
501497 with switch_db (A , "test2" ):
502498 a_doc .update (name = "a4" , upsert = True )
You can’t perform that action at this time.
0 commit comments