|
6 | 6 | from flask import current_app |
7 | 7 | from flask_testing import TestCase |
8 | 8 |
|
9 | | -from project.server import app |
| 9 | +from project.server import APP |
| 10 | + |
| 11 | +POSTGRES_LOCAL_BASE = 'postgresql://postgres:password@localhost/' |
| 12 | +DATABASE_NAME = 'python_flask_api_boilerplate' |
10 | 13 |
|
11 | 14 |
|
12 | 15 | class TestDevelopmentConfig(TestCase): |
| 16 | + """Testing App Development configuration""" |
| 17 | + |
13 | 18 | def create_app(self): |
14 | | - app.config.from_object('project.server.config.DevelopmentConfig') |
15 | | - return app |
| 19 | + """Get dev mode""" |
| 20 | + APP.config.from_object('project.server.config.DevelopmentConfig') |
| 21 | + return APP |
16 | 22 |
|
17 | 23 | def test_app_is_development(self): |
18 | | - self.assertFalse(app.config['SECRET_KEY'] is 'my_precious') |
19 | | - self.assertTrue(app.config['DEBUG'] is True) |
| 24 | + """Dev assertions method""" |
| 25 | + self.assertFalse(APP.config['SECRET_KEY'] is 'my_precious') |
| 26 | + self.assertTrue(APP.config['DEBUG'] is True) |
20 | 27 | self.assertFalse(current_app is None) |
21 | 28 | self.assertTrue( |
22 | | - app.config['SQLALCHEMY_DATABASE_URI'] == 'postgresql://postgres:password@localhost/python_flask_api_boilerplate' |
| 29 | + APP.config['SQLALCHEMY_DATABASE_URI'] == |
| 30 | + POSTGRES_LOCAL_BASE + DATABASE_NAME |
23 | 31 | ) |
24 | 32 |
|
25 | 33 |
|
26 | 34 | class TestTestingConfig(TestCase): |
| 35 | + """Testing App Test Configuration""" |
| 36 | + |
27 | 37 | def create_app(self): |
28 | | - app.config.from_object('project.server.config.TestingConfig') |
29 | | - return app |
| 38 | + """Get app test config""" |
| 39 | + APP.config.from_object('project.server.config.TestingConfig') |
| 40 | + return APP |
30 | 41 |
|
31 | 42 | def test_app_is_testing(self): |
32 | | - self.assertFalse(app.config['SECRET_KEY'] is 'my_precious') |
33 | | - self.assertTrue(app.config['DEBUG']) |
| 43 | + """Testing method assertions""" |
| 44 | + self.assertFalse(APP.config['SECRET_KEY'] is 'my_precious') |
| 45 | + self.assertTrue(APP.config['DEBUG']) |
34 | 46 | self.assertTrue( |
35 | | - app.config['SQLALCHEMY_DATABASE_URI'] == 'postgresql://postgres:password@localhost/python_flask_api_boilerplate_test' |
| 47 | + APP.config['SQLALCHEMY_DATABASE_URI'] == |
| 48 | + POSTGRES_LOCAL_BASE + DATABASE_NAME + '_test' |
36 | 49 | ) |
37 | 50 |
|
38 | 51 |
|
39 | 52 | class TestProductionConfig(TestCase): |
| 53 | + """Testing App Production Config""" |
| 54 | + |
40 | 55 | def create_app(self): |
41 | | - app.config.from_object('project.server.config.ProductionConfig') |
42 | | - return app |
| 56 | + """Get the production config""" |
| 57 | + APP.config.from_object('project.server.config.ProductionConfig') |
| 58 | + return APP |
43 | 59 |
|
44 | 60 | def test_app_is_production(self): |
45 | | - self.assertTrue(app.config['DEBUG'] is False) |
| 61 | + """Assert App Debug mode is false""" |
| 62 | + self.assertTrue(APP.config['DEBUG'] is False) |
46 | 63 |
|
47 | 64 |
|
48 | 65 | if __name__ == '__main__': |
|
0 commit comments