From 7de99f0723300eeeda9e3df3076bd3f7fefe8e37 Mon Sep 17 00:00:00 2001 From: Ilya Skriblovsky Date: Fri, 6 Jul 2018 00:17:23 +0300 Subject: [PATCH] Fixed tests against MongoDB 3.6 --- tests/mongod.py | 1 - tests/test_filters.py | 11 +++++++++-- tests/test_queries.py | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/mongod.py b/tests/mongod.py index 0d445641..336dcbc4 100644 --- a/tests/mongod.py +++ b/tests/mongod.py @@ -68,7 +68,6 @@ def start(self): b"--noprealloc", b"--nojournal", b"--smallfiles", b"--nssize", b"1", b"--oplogSize", b"1", - b"--nohttpinterface", ] if self.auth: args.append(b"--auth") if self.replset: args.extend([b"--replSet", self.replset]) diff --git a/tests/test_filters.py b/tests/test_filters.py index cb0f43f8..838f2656 100644 --- a/tests/test_filters.py +++ b/tests/test_filters.py @@ -80,6 +80,9 @@ def test_TextIndex(self): def __3_2_or_higher(self): return self.db.command("buildInfo").addCallback(lambda info: info["versionArray"] >= [3, 2]) + def __3_6_or_higher(self): + return self.db.command("buildInfo").addCallback(lambda info: info["versionArray"] >= [3, 6]) + @defer.inlineCallbacks def __test_simple_filter(self, filter, optionname, optionvalue): # Checking that `optionname` appears in profiler log with specified value @@ -88,7 +91,9 @@ def __test_simple_filter(self, filter, optionname, optionvalue): yield self.coll.find({}, filter=filter) yield self.db.command("profile", 0) - if (yield self.__3_2_or_higher()): + if (yield self.__3_6_or_higher()): + profile_filter = {"command." + optionname: optionvalue} + elif (yield self.__3_2_or_higher()): # query options format in system.profile have changed in MongoDB 3.2 profile_filter = {"query." + optionname: optionvalue} else: @@ -123,7 +128,9 @@ def test_FilterMerge(self): yield self.coll.find({}, filter=qf.sort(qf.ASCENDING('x')) + qf.comment(comment)) yield self.db.command("profile", 0) - if (yield self.__3_2_or_higher()): + if (yield self.__3_6_or_higher()): + profile_filter = {"command.sort.x": 1, "command.comment": comment} + elif (yield self.__3_2_or_higher()): profile_filter = {"query.sort.x": 1, "query.comment": comment} else: profile_filter = {"query.$orderby.x": 1, "query.$comment": comment} diff --git a/tests/test_queries.py b/tests/test_queries.py index de4538d9..cfcd04bc 100644 --- a/tests/test_queries.py +++ b/tests/test_queries.py @@ -415,7 +415,8 @@ def test_CheckResult(self): "delete", "mycol", check=True, allowable_errors=[ "missing deletes field", - "The deletes option is required to the delete command." + "The deletes option is required to the delete command.", + "BSON field 'delete.deletes' is missing but a required field" ] ) self.assertFalse(result["ok"])