Skip to content

Commit

Permalink
Fixed tests against MongoDB 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyaSkriblovsky committed Jul 5, 2018
1 parent af44a1b commit 7de99f0
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion tests/mongod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
11 changes: 9 additions & 2 deletions tests/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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}
Expand Down
3 changes: 2 additions & 1 deletion tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit 7de99f0

Please sign in to comment.