MCPcopy Create free account
hub / github.com/MongoEngine/mongoengine / test_connect

Method test_connect

tests/test_connection.py:60–79  ·  view source on GitHub ↗

Ensure that the connect() method works properly.

(self)

Source from the content-addressed store, hash-verified

58 mongoengine.connection._dbs = {}
59
60 def test_connect(self):
61 """Ensure that the connect() method works properly."""
62 connect("mongoenginetest")
63
64 conn = get_connection()
65 assert isinstance(conn, pymongo.MongoClient)
66
67 db = get_db()
68 assert isinstance(db, pymongo.database.Database)
69 assert db.name == "mongoenginetest"
70
71 connect("mongoenginetest2", alias="testdb")
72 conn = get_connection("testdb")
73 assert isinstance(conn, pymongo.MongoClient)
74
75 connect(
76 "mongoenginetest2", alias="testdb3", mongo_client_class=pymongo.MongoClient
77 )
78 conn = get_connection("testdb")
79 assert isinstance(conn, pymongo.MongoClient)
80
81 def test_connect_disconnect_works_properly(self):
82 class History1(Document):

Callers

nothing calls this directly

Calls 3

connectFunction · 0.90
get_connectionFunction · 0.90
get_dbFunction · 0.90

Tested by

no test coverage detected