PYTHON-1291 Skip *_with_invalid_keys tests against >= 3.5.8.

This commit is contained in:
Shane Harvey 2017-06-28 15:43:08 -07:00
parent 138255609e
commit a6eed38e54
2 changed files with 12 additions and 0 deletions

View File

@ -1401,6 +1401,8 @@ class TestCollection(IntegrationTest):
self.assertRaises(InvalidOperation, lambda: result.upserted_id)
self.assertFalse(result.acknowledged)
# MongoDB >= 3.5.8 allows dotted fields in updates
@client_context.require_version_max(3, 5, 7)
def test_update_with_invalid_keys(self):
self.db.drop_collection("test")
self.assertTrue(self.db.test.insert_one({"hello": "world"}))
@ -1421,6 +1423,14 @@ class TestCollection(IntegrationTest):
# Check that the last two ops didn't actually modify anything
self.assertTrue('a.b' not in self.db.test.find_one())
def test_update_check_keys(self):
self.db.drop_collection("test")
self.assertTrue(self.db.test.insert_one({"hello": "world"}))
expected = InvalidDocument
if client_context.version.at_least(2, 5, 4, -1):
expected = OperationFailure
# Modify shouldn't check keys...
self.assertTrue(self.db.test.update_one({"hello": "world"},
{"$set": {"foo.bar": "baz"}},

View File

@ -598,6 +598,8 @@ class TestLegacy(IntegrationTest):
self.db.drop_collection("test")
def test_save_with_invalid_key(self):
if client_context.version.at_least(3, 5, 8):
raise SkipTest("MongoDB >= 3.5.8 allows dotted fields in updates")
# Tests legacy save.
self.db.drop_collection("test")
self.assertTrue(self.db.test.insert({"hello": "world"}))