Skip to content

Commit e3c58c0

Browse files
committed
PYTHON-1291 Skip *_with_invalid_keys tests against >= 3.5.8.
1 parent b067e80 commit e3c58c0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/test_collection.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,6 +1014,8 @@ def test_save(self):
10141014
{'_id': 'explicit_id', 'hello': 'world'})
10151015

10161016
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")
10171019
self.db.drop_collection("test")
10181020
self.assertTrue(self.db.test.insert({"hello": "world"}))
10191021
doc = self.db.test.find_one()
@@ -1307,6 +1309,8 @@ def test_safe_update(self):
13071309
{"$inc": {"x": 2}})["n"])
13081310

13091311
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")
13101314
self.db.drop_collection("test")
13111315
self.assertTrue(self.db.test.insert({"hello": "world"}))
13121316
doc = self.db.test.find_one()
@@ -1326,6 +1330,14 @@ def test_update_with_invalid_keys(self):
13261330
# Check that the last two ops didn't actually modify anything
13271331
self.assertTrue('a.b' not in self.db.test.find_one())
13281332

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+
13291341
# Modify shouldn't check keys...
13301342
self.assertTrue(self.db.test.update({"hello": "world"},
13311343
{"$set": {"foo.bar": "baz"}},
@@ -2862,6 +2874,8 @@ def test_backport_update_many(self):
28622874

28632875

28642876
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")
28652879
self.db.drop_collection("test")
28662880
self.assertTrue(self.db.test.insert_one({"hello": "world"}))
28672881
doc = self.db.test.find_one()
@@ -2881,6 +2895,13 @@ def test_backport_update_with_invalid_keys(self):
28812895
# Check that the last two ops didn't actually modify anything
28822896
self.assertTrue('a.b' not in self.db.test.find_one())
28832897

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
28842905
# Modify shouldn't check keys...
28852906
self.assertTrue(self.db.test.update_one({"hello": "world"},
28862907
{"$set": {"foo.bar": "baz"}},

0 commit comments

Comments
 (0)