Skip to content

Commit ccafaaa

Browse files
committed
mongomock tests: Python2.6 compatibility
1 parent 24bbdff commit ccafaaa

File tree

1 file changed

+23
-24
lines changed

1 file changed

+23
-24
lines changed

tests/test_connection.py

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,31 @@
66
from flask.ext.mongoengine import MongoEngine
77
from tests import FlaskMongoEngineTestCase
88

9+
910
class ConnectionTestCase(FlaskMongoEngineTestCase):
1011

11-
def test_ignore_parse_uri_if_testing_true_and_uses_mongomock_schema(self):
12-
self.app.config['TESTING'] = True
13-
self.app.config['MONGODB_ALIAS'] = 'unittest'
14-
self.app.config['MONGODB_HOST'] = 'mongomock://localhost'
15-
16-
if StrictVersion(mongoengine.__version__) >= StrictVersion('0.10.6'):
17-
db = MongoEngine(self.app)
18-
self.assertTrue(isinstance(db.connection, mongomock.MongoClient))
19-
20-
def test_parse_uri_if_testing_true_and_not_uses_mongomock_schema(self):
21-
self.app.config['TESTING'] = True
22-
self.app.config['MONGODB_ALIAS'] = 'unittest'
23-
self.app.config['MONGODB_HOST'] = 'mongo://localhost'
24-
25-
with self.assertRaises(InvalidURI):
26-
db = MongoEngine(self.app)
27-
28-
def test_parse_uri_if_testing_is_not_true(self):
29-
self.app.config['TESTING'] = False
30-
self.app.config['MONGODB_ALIAS'] = 'unittest'
31-
self.app.config['MONGODB_HOST'] = 'mongomock://localhost'
32-
33-
with self.assertRaises(InvalidURI):
34-
db = MongoEngine(self.app)
12+
def test_ignore_parse_uri_if_testing_true_and_uses_mongomock_schema(self):
13+
self.app.config['TESTING'] = True
14+
self.app.config['MONGODB_ALIAS'] = 'unittest'
15+
self.app.config['MONGODB_HOST'] = 'mongomock://localhost'
16+
17+
if StrictVersion(mongoengine.__version__) >= StrictVersion('0.10.6'):
18+
db = MongoEngine(self.app)
19+
self.assertTrue(isinstance(db.connection, mongomock.MongoClient))
20+
21+
def test_parse_uri_if_testing_true_and_not_uses_mongomock_schema(self):
22+
self.app.config['TESTING'] = True
23+
self.app.config['MONGODB_ALIAS'] = 'unittest'
24+
self.app.config['MONGODB_HOST'] = 'mongo://localhost'
25+
26+
self.assertRaises(InvalidURI, MongoEngine, self.app)
27+
28+
def test_parse_uri_if_testing_not_true(self):
29+
self.app.config['TESTING'] = False
30+
self.app.config['MONGODB_ALIAS'] = 'unittest'
31+
self.app.config['MONGODB_HOST'] = 'mongomock://localhost'
32+
33+
self.assertRaises(InvalidURI, MongoEngine, self.app)
3534

3635
if __name__ == '__main__':
3736
unittest.main()

0 commit comments

Comments
 (0)