Files
test-driven/services/users/project/tests/test_config.py
2019-11-14 16:16:31 +01:00

56 lines
1.6 KiB
Python

import os
import unittest
from flask import current_app
from flask_testing import TestCase
from project import create_app
app = create_app()
class TestDevelopmentConfig(TestCase):
def create_app(self):
app.config.from_object('project.config.DevelopmentConfig')
return app
def test_app_is_development(self):
self.assertTrue(app.config['SECRET_KEY'] == 'my_precious')
self.assertFalse(current_app is None)
self.assertTrue(
app.config['SQLALCHEMY_DATABASE_URI'] ==
os.environ.get('DATABASE_URL')
)
self.assertTrue(app.config['DEBUG_TB_ENABLED'])
class TestTestingConfig(TestCase):
def create_app(self):
app.config.from_object('project.config.TestingConfig')
return app
def test_app_is_testing(self):
self.assertTrue(app.config['SECRET_KEY'] == 'my_precious')
self.assertTrue(app.config['TESTING'])
self.assertFalse(app.config['PRESERVE_CONTEXT_ON_EXCEPTION'])
self.assertTrue(
app.config['SQLALCHEMY_DATABASE_URI'] ==
os.environ.get('DATABASE_TEST_URL')
)
self.assertFalse(app.config['DEBUG_TB_ENABLED'])
class TestProductionConfig(TestCase):
def create_app(self):
app.config.from_object('project.config.ProductionConfig')
return app
def test_app_is_testing(self):
self.assertTrue(app.config['SECRET_KEY'] == 'my_precious')
self.assertFalse(app.config['TESTING'])
self.assertFalse(app.config['DEBUG_TB_ENABLED'])
if __name__ == "__main__":
unittest.main()