2017-07-01 17:48:18 -07:00
|
|
|
# kappa123/server/tests/test_config.py
|
2015-01-21 08:32:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
import unittest
|
|
|
|
|
|
|
|
from flask import current_app
|
2016-07-17 03:47:20 -07:00
|
|
|
from flask_testing import TestCase
|
2015-01-21 08:32:17 -08:00
|
|
|
|
2017-07-01 17:48:18 -07:00
|
|
|
from kappa123.server import app
|
2015-01-21 08:32:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
class TestDevelopmentConfig(TestCase):
|
|
|
|
|
|
|
|
def create_app(self):
|
2017-07-01 17:48:18 -07:00
|
|
|
app.config.from_object('kappa123.server.config.DevelopmentConfig')
|
2015-01-21 08:32:17 -08:00
|
|
|
return app
|
|
|
|
|
|
|
|
def test_app_is_development(self):
|
|
|
|
self.assertFalse(current_app.config['TESTING'])
|
|
|
|
self.assertTrue(app.config['DEBUG'] is True)
|
|
|
|
self.assertTrue(app.config['WTF_CSRF_ENABLED'] is False)
|
|
|
|
self.assertTrue(app.config['DEBUG_TB_ENABLED'] is True)
|
|
|
|
self.assertFalse(current_app is None)
|
|
|
|
|
|
|
|
|
|
|
|
class TestTestingConfig(TestCase):
|
|
|
|
|
|
|
|
def create_app(self):
|
2017-07-01 17:48:18 -07:00
|
|
|
app.config.from_object('kappa123.server.config.TestingConfig')
|
2015-01-21 08:32:17 -08:00
|
|
|
return app
|
|
|
|
|
|
|
|
def test_app_is_testing(self):
|
|
|
|
self.assertTrue(current_app.config['TESTING'])
|
|
|
|
self.assertTrue(app.config['DEBUG'] is True)
|
2015-12-25 05:00:00 -08:00
|
|
|
self.assertTrue(app.config['BCRYPT_LOG_ROUNDS'] == 4)
|
2015-01-21 08:32:17 -08:00
|
|
|
self.assertTrue(app.config['WTF_CSRF_ENABLED'] is False)
|
|
|
|
|
|
|
|
|
|
|
|
class TestProductionConfig(TestCase):
|
|
|
|
|
|
|
|
def create_app(self):
|
2017-07-01 17:48:18 -07:00
|
|
|
app.config.from_object('kappa123.server.config.ProductionConfig')
|
2015-01-21 08:32:17 -08:00
|
|
|
return app
|
|
|
|
|
|
|
|
def test_app_is_production(self):
|
|
|
|
self.assertFalse(current_app.config['TESTING'])
|
|
|
|
self.assertTrue(app.config['DEBUG'] is False)
|
|
|
|
self.assertTrue(app.config['DEBUG_TB_ENABLED'] is False)
|
|
|
|
self.assertTrue(app.config['WTF_CSRF_ENABLED'] is True)
|
|
|
|
self.assertTrue(app.config['BCRYPT_LOG_ROUNDS'] == 13)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
unittest.main()
|