@@ -816,14 +816,18 @@ def test_core(self):
816
816
self .assertEqual (sess .cluster_time , sess2 .cluster_time )
817
817
self .assertEqual (sess .operation_time , sess2 .operation_time )
818
818
819
- def _test_reads (self , op ):
819
+ def _test_reads (self , op , exception = None ):
820
820
coll = self .client .pymongo_test .test
821
821
with self .client .start_session () as sess :
822
822
coll .find_one ({}, session = sess )
823
823
operation_time = sess .operation_time
824
824
self .assertIsNotNone (operation_time )
825
825
self .listener .results .clear ()
826
- op (coll , sess )
826
+ if exception :
827
+ with self .assertRaises (exception ):
828
+ op (coll , sess )
829
+ else :
830
+ op (coll , sess )
827
831
act = self .listener .results ['started' ][0 ].command .get (
828
832
'readConcern' , {}).get ('afterClusterTime' )
829
833
self .assertEqual (operation_time , act )
@@ -844,12 +848,19 @@ def test_reads(self):
844
848
lambda coll , session : coll .count_documents ({}, session = session ))
845
849
self ._test_reads (
846
850
lambda coll , session : coll .distinct ('foo' , session = session ))
851
+
852
+ # SERVER-40938 removed support for casually consistent mapReduce.
853
+ map_reduce_exc = None
854
+ if client_context .version .at_least (4 , 1 , 12 ):
855
+ map_reduce_exc = OperationFailure
847
856
self ._test_reads (
848
857
lambda coll , session : coll .map_reduce (
849
- 'function() {}' , 'function() {}' , 'inline' , session = session ))
858
+ 'function() {}' , 'function() {}' , 'inline' , session = session ),
859
+ exception = map_reduce_exc )
850
860
self ._test_reads (
851
861
lambda coll , session : coll .inline_map_reduce (
852
- 'function() {}' , 'function() {}' , session = session ))
862
+ 'function() {}' , 'function() {}' , session = session ),
863
+ exception = map_reduce_exc )
853
864
if (not client_context .is_mongos and
854
865
not client_context .version .at_least (4 , 1 , 0 )):
855
866
def scan (coll , session ):
0 commit comments