Skip to content

Commit 8b338a8

Browse files
committed
[Bug] 🐛 Fix base test config bug
1 parent ce79989 commit 8b338a8

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

project/tests/test_config.py

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,43 +6,60 @@
66
from flask import current_app
77
from flask_testing import TestCase
88

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'
1013

1114

1215
class TestDevelopmentConfig(TestCase):
16+
"""Testing App Development configuration"""
17+
1318
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
1622

1723
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)
2027
self.assertFalse(current_app is None)
2128
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
2331
)
2432

2533

2634
class TestTestingConfig(TestCase):
35+
"""Testing App Test Configuration"""
36+
2737
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
3041

3142
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'])
3446
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'
3649
)
3750

3851

3952
class TestProductionConfig(TestCase):
53+
"""Testing App Production Config"""
54+
4055
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
4359

4460
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)
4663

4764

4865
if __name__ == '__main__':

0 commit comments

Comments
 (0)