@@ -688,15 +688,6 @@ def _test_reads(self, op):
688
688
689
689
@client_context .require_no_standalone
690
690
def test_reads (self ):
691
- self ._test_reads (
692
- lambda coll , session : list (
693
- coll .database .list_collections (session = session )))
694
- self ._test_reads (
695
- lambda coll , session : coll .database .list_collection_names (
696
- session = session ))
697
- self ._test_reads (
698
- lambda coll , session : coll .database .command (
699
- 'ismaster' , session = session ))
700
691
self ._test_reads (
701
692
lambda coll , session : list (coll .aggregate ([], session = session )))
702
693
self ._test_reads (
@@ -705,17 +696,11 @@ def test_reads(self):
705
696
lambda coll , session : coll .find_one ({}, session = session ))
706
697
self ._test_reads (
707
698
lambda coll , session : coll .count (session = session ))
708
- self ._test_reads (
709
- lambda coll , session : list (coll .list_indexes (session = session )))
710
- self ._test_reads (
711
- lambda coll , session : coll .index_information (session = session ))
712
- self ._test_reads (
713
- lambda coll , session : coll .options (session = session ))
714
699
self ._test_reads (
715
700
lambda coll , session : coll .distinct ('foo' , session = session ))
716
701
self ._test_reads (
717
702
lambda coll , session : coll .map_reduce (
718
- 'function() {}' , 'function() {}' , 'output ' , session = session ))
703
+ 'function() {}' , 'function() {}' , 'inline ' , session = session ))
719
704
self ._test_reads (
720
705
lambda coll , session : coll .inline_map_reduce (
721
706
'function() {}' , 'function() {}' , session = session ))
@@ -793,6 +778,87 @@ def test_writes(self):
793
778
self ._test_writes (
794
779
lambda coll , session : coll .reindex (session = session ))
795
780
781
+ def _test_no_read_concern (self , op ):
782
+ coll = self .client .pymongo_test .test
783
+ with self .client .start_session () as sess :
784
+ coll .find_one ({}, session = sess )
785
+ operation_time = sess .operation_time
786
+ self .assertIsNotNone (operation_time )
787
+ self .listener .results .clear ()
788
+ op (coll , sess )
789
+ rc = self .listener .results ['started' ][0 ].command .get (
790
+ 'readConcern' )
791
+ self .assertIsNone (rc )
792
+
793
+ @client_context .require_no_standalone
794
+ def test_writes_do_not_include_read_concern (self ):
795
+ self ._test_no_read_concern (
796
+ lambda coll , session : coll .bulk_write (
797
+ [InsertOne ({})], session = session ))
798
+ self ._test_no_read_concern (
799
+ lambda coll , session : coll .insert_one ({}, session = session ))
800
+ self ._test_no_read_concern (
801
+ lambda coll , session : coll .insert_many ([{}], session = session ))
802
+ self ._test_no_read_concern (
803
+ lambda coll , session : coll .replace_one (
804
+ {'_id' : 1 }, {'x' : 1 }, session = session ))
805
+ self ._test_no_read_concern (
806
+ lambda coll , session : coll .update_one (
807
+ {}, {'$set' : {'X' : 1 }}, session = session ))
808
+ self ._test_no_read_concern (
809
+ lambda coll , session : coll .update_many (
810
+ {}, {'$set' : {'x' : 1 }}, session = session ))
811
+ self ._test_no_read_concern (
812
+ lambda coll , session : coll .delete_one ({}, session = session ))
813
+ self ._test_no_read_concern (
814
+ lambda coll , session : coll .delete_many ({}, session = session ))
815
+ self ._test_no_read_concern (
816
+ lambda coll , session : coll .find_one_and_replace (
817
+ {'x' : 1 }, {'y' : 1 }, session = session ))
818
+ self ._test_no_read_concern (
819
+ lambda coll , session : coll .find_one_and_update (
820
+ {'y' : 1 }, {'$set' : {'x' : 1 }}, session = session ))
821
+ self ._test_no_read_concern (
822
+ lambda coll , session : coll .find_one_and_delete (
823
+ {'x' : 1 }, session = session ))
824
+ self ._test_no_read_concern (
825
+ lambda coll , session : coll .create_index ("foo" , session = session ))
826
+ self ._test_no_read_concern (
827
+ lambda coll , session : coll .create_indexes (
828
+ [IndexModel ([("bar" , ASCENDING )])], session = session ))
829
+ self ._test_no_read_concern (
830
+ lambda coll , session : coll .drop_index ("foo_1" , session = session ))
831
+ self ._test_no_read_concern (
832
+ lambda coll , session : coll .drop_indexes (session = session ))
833
+ self ._test_no_read_concern (
834
+ lambda coll , session : coll .reindex (session = session ))
835
+ self ._test_no_read_concern (
836
+ lambda coll , session : list (
837
+ coll .aggregate ([{"$out" : "aggout" }], session = session )))
838
+ self ._test_no_read_concern (
839
+ lambda coll , session : coll .map_reduce (
840
+ 'function() {}' , 'function() {}' , 'mrout' , session = session ))
841
+
842
+ # It's not a write, but currentOp also doesn't support readConcern
843
+ self ._test_no_read_concern (
844
+ lambda coll , session : coll .database .current_op (session = session ))
845
+
846
+ @client_context .require_no_standalone
847
+ def test_get_more_does_not_include_read_concern (self ):
848
+ coll = self .client .pymongo_test .test
849
+ with self .client .start_session () as sess :
850
+ coll .find_one ({}, session = sess )
851
+ operation_time = sess .operation_time
852
+ self .assertIsNotNone (operation_time )
853
+ coll .insert_many ([{}, {}])
854
+ cursor = coll .find ({}).batch_size (1 )
855
+ next (cursor )
856
+ self .listener .results .clear ()
857
+ list (cursor )
858
+ started = self .listener .results ['started' ][0 ]
859
+ self .assertEqual (started .command_name , 'getMore' )
860
+ self .assertIsNone (started .command .get ('readConcern' ))
861
+
796
862
def test_session_not_causal (self ):
797
863
with self .client .start_session (causal_consistency = False ) as s :
798
864
self .client .pymongo_test .test .insert_one ({}, session = s )
0 commit comments