Skip to content

Commit e86bbb1

Browse files
committed
fix the tests
1 parent 4547b79 commit e86bbb1

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

tests/test_connection.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from flask_mongoengine import MongoEngine
77

8-
from .tests import FlaskMongoEngineTestCase
8+
from tests import FlaskMongoEngineTestCase
99

1010

1111
class ConnectionTestCase(FlaskMongoEngineTestCase):
@@ -36,20 +36,27 @@ def test_simple_connection(self):
3636
"""Make sure a simple connection to a standalone MongoDB works."""
3737
db = MongoEngine()
3838
self.app.config['MONGODB_SETTINGS'] = {
39+
'ALIAS': 'simple_conn',
3940
'HOST': 'localhost',
4041
'PORT': 27017,
4142
'DB': 'flask_mongoengine_test_db'
4243
}
4344
self._do_persist(db)
4445

45-
def test_connection_with_uri_string(self):
46+
def test_host_as_uri_string(self):
4647
"""Make sure we can connect to a standalone MongoDB if we specify
4748
the host as a MongoDB URI.
4849
"""
4950
db = MongoEngine()
5051
self.app.config['MONGODB_HOST'] = 'mongodb://localhost:27017/flask_mongoengine_test_db'
5152
self._do_persist(db)
5253

54+
def test_host_as_list(self):
55+
"""Make sure MONGODB_HOST can be a list hosts."""
56+
db = MongoEngine()
57+
self.app.config['MONGODB_HOST'] = ['localhost:27017']
58+
self._do_persist(db)
59+
5360
def test_multiple_connections(self):
5461
"""Make sure establishing multiple connections to a standalone
5562
MongoDB and switching between them works.
@@ -120,16 +127,17 @@ def test_connection_kwargs(self):
120127
MAX_POOL_SIZE_KEY = 'MAX_POOL_SIZE'
121128

122129
self.app.config['MONGODB_SETTINGS'] = {
130+
'ALIAS': 'tz_aware_true',
123131
'DB': 'flask_mongoengine_testing_tz_aware',
124132
'TZ_AWARE': True,
125133
'READ_PREFERENCE': ReadPreference.SECONDARY,
126134
MAX_POOL_SIZE_KEY: 10,
127135
}
128136
db = MongoEngine()
129137
db.init_app(self.app)
130-
self.assertTrue(db.connection.client.codec_options.tz_aware)
131-
self.assertEqual(db.connection.client.max_pool_size, 10)
138+
self.assertTrue(db.connection.codec_options.tz_aware)
139+
self.assertEqual(db.connection.max_pool_size, 10)
132140
self.assertEqual(
133-
db.connection.client.read_preference,
141+
db.connection.read_preference,
134142
ReadPreference.SECONDARY
135143
)

0 commit comments

Comments
 (0)