File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ from __future__ import annotations
2
+
3
+ from test import PyMongoTestCase
4
+
5
+ import pytest
6
+
7
+ try :
8
+ from mockupdb import MockupDB , OpMsg , going
9
+
10
+ _HAVE_MOCKUPDB = True
11
+ except ImportError :
12
+ _HAVE_MOCKUPDB = False
13
+
14
+
15
+ from bson .objectid import ObjectId
16
+
17
+ pytestmark = pytest .mark .mockupdb
18
+
19
+
20
+ class TestIdOrdering (PyMongoTestCase ):
21
+ def test_id_ordering (self ):
22
+ server = MockupDB ()
23
+ server .autoresponds (
24
+ "hello" ,
25
+ isWritablePrimary = True ,
26
+ msg = "isdbgrid" ,
27
+ minWireVersion = 0 ,
28
+ maxWireVersion = 20 ,
29
+ helloOk = True ,
30
+ serviceId = ObjectId (),
31
+ )
32
+ server .run ()
33
+ self .addCleanup (server .stop )
34
+
35
+ client = self .simple_client (server .uri , loadBalanced = True )
36
+ collection = client .db .coll
37
+ with going (collection .insert_one , {"x" : 1 }):
38
+ request = server .receives (OpMsg ({"insert" : "coll" }))
39
+ self .assertEqual ("_id" , next (iter (request ["documents" ][0 ])))
40
+ request .reply ({"ok" : 1 })
You can’t perform that action at this time.
0 commit comments