|
6 | 6 | from flask.ext.mongoengine import MongoEngine |
7 | 7 | from tests import FlaskMongoEngineTestCase |
8 | 8 |
|
| 9 | + |
9 | 10 | class ConnectionTestCase(FlaskMongoEngineTestCase): |
10 | 11 |
|
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) |
35 | 34 |
|
36 | 35 | if __name__ == '__main__': |
37 | 36 | unittest.main() |
0 commit comments