File tree Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Expand file tree Collapse file tree 3 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -1901,13 +1901,16 @@ class AggPerson(Document):
19011901
19021902 comment = "test_comment"
19031903
1904- with db_ops_tracker () as q :
1905- _ = AggPerson .objects ().comment (comment ).delete ()
1906- query_op = q .db .system .profile .find ({"ns" : "mongoenginetest.agg_person" })[0 ]
1907- CMD_QUERY_KEY = "command" if mongo_ver >= MONGODB_36 else "query"
1908- assert "hint" not in query_op [CMD_QUERY_KEY ]
1909- assert query_op [CMD_QUERY_KEY ]["comment" ] == comment
1910- assert "collation" not in query_op [CMD_QUERY_KEY ]
1904+ if PYMONGO_VERSION >= (4 , 1 ):
1905+ with db_ops_tracker () as q :
1906+ _ = AggPerson .objects ().comment (comment ).delete ()
1907+ query_op = q .db .system .profile .find (
1908+ {"ns" : "mongoenginetest.agg_person" }
1909+ )[0 ]
1910+ CMD_QUERY_KEY = "command" if mongo_ver >= MONGODB_36 else "query"
1911+ assert "hint" not in query_op [CMD_QUERY_KEY ]
1912+ assert query_op [CMD_QUERY_KEY ]["comment" ] == comment
1913+ assert "collation" not in query_op [CMD_QUERY_KEY ]
19111914
19121915 with db_ops_tracker () as q :
19131916 _ = AggPerson .objects .hint (index_name ).delete ()
Original file line number Diff line number Diff line change 88 MONGODB_36 ,
99 get_mongodb_version ,
1010)
11+ from mongoengine .pymongo_support import PYMONGO_VERSION
1112from tests .utils import MongoDBTestCase , db_ops_tracker
1213
1314BIN_VALUE = "\xa9 \xf3 \x8d (\xd7 \x03 \x84 \xb4 k[\x0f \xe3 \xa2 \x19 \x85 p[J\xa3 \xd2 >\xde \xe6 \x87 \xb1 \x7f \xc6 \xe6 \xd9 r\x18 \xf5 " .encode (
@@ -169,13 +170,16 @@ class AggPerson(Document):
169170
170171 comment = "test_comment"
171172
172- with db_ops_tracker () as q :
173- _ = AggPerson .objects .comment (comment ).update_one (name = "something" )
174- query_op = q .db .system .profile .find ({"ns" : "mongoenginetest.agg_person" })[0 ]
175- CMD_QUERY_KEY = "command" if mongo_ver >= MONGODB_36 else "query"
176- assert "hint" not in query_op [CMD_QUERY_KEY ]
177- assert query_op [CMD_QUERY_KEY ]["comment" ] == comment
178- assert "collation" not in query_op [CMD_QUERY_KEY ]
173+ if PYMONGO_VERSION >= (4 , 1 ):
174+ with db_ops_tracker () as q :
175+ _ = AggPerson .objects .comment (comment ).update_one (name = "something" )
176+ query_op = q .db .system .profile .find (
177+ {"ns" : "mongoenginetest.agg_person" }
178+ )[0 ]
179+ CMD_QUERY_KEY = "command" if mongo_ver >= MONGODB_36 else "query"
180+ assert "hint" not in query_op [CMD_QUERY_KEY ]
181+ assert query_op [CMD_QUERY_KEY ]["comment" ] == comment
182+ assert "collation" not in query_op [CMD_QUERY_KEY ]
179183
180184 with db_ops_tracker () as q :
181185 _ = AggPerson .objects .hint (index_name ).update_one (name = "something" )
Original file line number Diff line number Diff line change 22import operator
33import unittest
44
5+ import pymongo
56import pytest
67
78from mongoengine import connect
89from mongoengine .connection import disconnect_all , get_db
910from mongoengine .context_managers import query_counter
1011from mongoengine .mongodb_support import get_mongodb_version
1112
13+ PYMONGO_VERSION = tuple (pymongo .version_tuple [:2 ])
14+
1215MONGO_TEST_DB = "mongoenginetest" # standard name for the test database
1316
1417
You can’t perform that action at this time.
0 commit comments