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):
1901
1901
1902
1902
comment = "test_comment"
1903
1903
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 ]
1911
1914
1912
1915
with db_ops_tracker () as q :
1913
1916
_ = AggPerson .objects .hint (index_name ).delete ()
Original file line number Diff line number Diff line change 8
8
MONGODB_36 ,
9
9
get_mongodb_version ,
10
10
)
11
+ from mongoengine .pymongo_support import PYMONGO_VERSION
11
12
from tests .utils import MongoDBTestCase , db_ops_tracker
12
13
13
14
BIN_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):
169
170
170
171
comment = "test_comment"
171
172
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 ]
179
183
180
184
with db_ops_tracker () as q :
181
185
_ = AggPerson .objects .hint (index_name ).update_one (name = "something" )
Original file line number Diff line number Diff line change 2
2
import operator
3
3
import unittest
4
4
5
+ import pymongo
5
6
import pytest
6
7
7
8
from mongoengine import connect
8
9
from mongoengine .connection import disconnect_all , get_db
9
10
from mongoengine .context_managers import query_counter
10
11
from mongoengine .mongodb_support import get_mongodb_version
11
12
13
+ PYMONGO_VERSION = tuple (pymongo .version_tuple [:2 ])
14
+
12
15
MONGO_TEST_DB = "mongoenginetest" # standard name for the test database
13
16
14
17
You can’t perform that action at this time.
0 commit comments