@@ -1014,6 +1014,8 @@ def test_save(self):
1014
1014
{'_id' : 'explicit_id' , 'hello' : 'world' })
1015
1015
1016
1016
def test_save_with_invalid_key (self ):
1017
+ if version .at_least (self .db .connection , (3 , 5 , 8 )):
1018
+ raise SkipTest ("MongoDB >= 3.5.8 allows dotted fields in updates" )
1017
1019
self .db .drop_collection ("test" )
1018
1020
self .assertTrue (self .db .test .insert ({"hello" : "world" }))
1019
1021
doc = self .db .test .find_one ()
@@ -1307,6 +1309,8 @@ def test_safe_update(self):
1307
1309
{"$inc" : {"x" : 2 }})["n" ])
1308
1310
1309
1311
def test_update_with_invalid_keys (self ):
1312
+ if version .at_least (self .db .connection , (3 , 5 , 8 )):
1313
+ raise SkipTest ("MongoDB >= 3.5.8 allows dotted fields in updates" )
1310
1314
self .db .drop_collection ("test" )
1311
1315
self .assertTrue (self .db .test .insert ({"hello" : "world" }))
1312
1316
doc = self .db .test .find_one ()
@@ -1326,6 +1330,14 @@ def test_update_with_invalid_keys(self):
1326
1330
# Check that the last two ops didn't actually modify anything
1327
1331
self .assertTrue ('a.b' not in self .db .test .find_one ())
1328
1332
1333
+ def test_update_check_keys (self ):
1334
+ self .db .drop_collection ("test" )
1335
+ self .assertTrue (self .db .test .insert ({"hello" : "world" }))
1336
+
1337
+ expected = InvalidDocument
1338
+ if version .at_least (self .client , (2 , 5 , 4 , - 1 )):
1339
+ expected = OperationFailure
1340
+
1329
1341
# Modify shouldn't check keys...
1330
1342
self .assertTrue (self .db .test .update ({"hello" : "world" },
1331
1343
{"$set" : {"foo.bar" : "baz" }},
@@ -2862,6 +2874,8 @@ def test_backport_update_many(self):
2862
2874
2863
2875
2864
2876
def test_backport_update_with_invalid_keys (self ):
2877
+ if version .at_least (self .db .connection , (3 , 5 , 8 )):
2878
+ raise SkipTest ("MongoDB >= 3.5.8 allows dotted fields in updates" )
2865
2879
self .db .drop_collection ("test" )
2866
2880
self .assertTrue (self .db .test .insert_one ({"hello" : "world" }))
2867
2881
doc = self .db .test .find_one ()
@@ -2881,6 +2895,13 @@ def test_backport_update_with_invalid_keys(self):
2881
2895
# Check that the last two ops didn't actually modify anything
2882
2896
self .assertTrue ('a.b' not in self .db .test .find_one ())
2883
2897
2898
+ def test_backport_update_check_keys (self ):
2899
+ self .db .drop_collection ("test" )
2900
+ self .assertTrue (self .db .test .insert_one ({"hello" : "world" }))
2901
+
2902
+ expected = InvalidDocument
2903
+ if version .at_least (self .client , (2 , 5 , 4 , - 1 )):
2904
+ expected = OperationFailure
2884
2905
# Modify shouldn't check keys...
2885
2906
self .assertTrue (self .db .test .update_one ({"hello" : "world" },
2886
2907
{"$set" : {"foo.bar" : "baz" }},
0 commit comments