@@ -1003,7 +1003,8 @@ def test_error_code(self):
10031003 self .fail ()
10041004 except OperationFailure , e :
10051005 if version .at_least (self .db .connection , (1 , 3 )):
1006- self .assertEqual (10147 , e .code )
1006+ if e .code not in (10147 , 17009 ):
1007+ self .fail ()
10071008
10081009 def test_index_on_subfield (self ):
10091010 db = self .db
@@ -1889,14 +1890,19 @@ def test_bad_dbref(self):
18891890 ref_only = {'ref' : {'$ref' : 'collection' }}
18901891 id_only = {'ref' : {'$id' : ObjectId ()}}
18911892
1892- # Force insert of ref without $id.
1893- c .insert (ref_only , check_keys = False )
1894- self .assertEqual (DBRef ('collection' , id = None ), c .find_one ()['ref' ])
1895- c .drop ()
1893+ # Starting with MongoDB 2.5.2 this is no longer possible
1894+ # from insert, update, or findAndModify.
1895+ if not version .at_least (self .db .connection , (2 , 5 , 2 )):
1896+ # Force insert of ref without $id.
1897+ c .insert (ref_only , check_keys = False )
1898+ self .assertEqual (DBRef ('collection' , id = None ),
1899+ c .find_one ()['ref' ])
1900+
1901+ c .drop ()
18961902
1897- # DBRef without $ref is decoded as normal subdocument.
1898- c .insert (id_only , check_keys = False )
1899- self .assertEqual (id_only , c .find_one ())
1903+ # DBRef without $ref is decoded as normal subdocument.
1904+ c .insert (id_only , check_keys = False )
1905+ self .assertEqual (id_only , c .find_one ())
19001906
19011907 def test_as_class (self ):
19021908 c = self .db .test
0 commit comments