@@ -751,11 +751,11 @@ def test_multiple_error_unordered_batch(self):
751751 try :
752752 batch = self .coll .initialize_unordered_bulk_op ()
753753 batch .insert ({'b' : 1 , 'a' : 1 })
754- batch .find ({'b' : 2 }).upsert ().update_one ({'$set' : {'a' : 1 }})
755- batch .find ({'b' : 3 }).upsert ().update_one ({'$set' : {'a' : 2 }})
756- batch .find ({'b' : 2 }).upsert ().update_one ({'$set' : {'a' : 1 }})
757- batch .insert ({'b' : 4 , 'a' : 3 })
758- batch .insert ({'b' : 5 , 'a' : 1 })
754+ batch .find ({'b' : 2 }).upsert ().update_one ({'$set' : {'a' : 3 }})
755+ batch .find ({'b' : 3 }).upsert ().update_one ({'$set' : {'a' : 4 }})
756+ batch .find ({'b' : 4 }).upsert ().update_one ({'$set' : {'a' : 3 }})
757+ batch .insert ({'b' : 5 , 'a' : 2 })
758+ batch .insert ({'b' : 6 , 'a' : 1 })
759759
760760 try :
761761 batch .execute ()
@@ -764,33 +764,30 @@ def test_multiple_error_unordered_batch(self):
764764 self .assertEqual (exc .code , 65 )
765765 else :
766766 self .fail ("Error not raised" )
767+ # Assume the update at index 1 runs before the update at index 3,
768+ # although the spec does not require it. Same for inserts.
767769 self .assertEqualResponse (
768770 {'nMatched' : 0 ,
769771 'nModified' : 0 ,
770- 'nUpserted' : 1 ,
772+ 'nUpserted' : 2 ,
771773 'nInserted' : 2 ,
772774 'nRemoved' : 0 ,
773- 'upserted' : [{'index' : 2 , '_id' : '...' }],
775+ 'upserted' : [
776+ {'index' : 1 , '_id' : '...' },
777+ {'index' : 2 , '_id' : '...' }],
774778 'writeConcernErrors' : [],
775779 'writeErrors' : [
776- {'index' : 1 ,
777- 'code' : 11000 ,
778- 'errmsg' : '...' ,
779- 'op' : {'q' : {'b' : 2 },
780- 'u' : {'$set' : {'a' : 1 }},
781- 'multi' : False ,
782- 'upsert' : True }},
783780 {'index' : 3 ,
784781 'code' : 11000 ,
785782 'errmsg' : '...' ,
786- 'op' : {'q' : {'b' : 2 },
787- 'u' : {'$set' : {'a' : 1 }},
783+ 'op' : {'q' : {'b' : 4 },
784+ 'u' : {'$set' : {'a' : 3 }},
788785 'multi' : False ,
789786 'upsert' : True }},
790787 {'index' : 5 ,
791788 'code' : 11000 ,
792789 'errmsg' : '...' ,
793- 'op' : {'_id' : '...' , 'b' : 5 , 'a' : 1 }}]},
790+ 'op' : {'_id' : '...' , 'b' : 6 , 'a' : 1 }}]},
794791 result )
795792 finally :
796793 self .coll .drop_index ([('a' , 1 )])
0 commit comments