reorder config imports for more specific overrides

This commit is contained in:
Brian S. Stephan 2020-03-07 19:37:02 -06:00
parent 5f5301e9c9
commit ab009e4f59
3 changed files with 19 additions and 7 deletions

View File

@ -17,12 +17,11 @@ def create_app(instance_path=None, test_config=None):
# if it doesn't already exist, create the instance folder
os.makedirs(app.instance_path, exist_ok=True)
if test_config is None:
# load defaults from config provided with the application
app.config.from_object('incorporealcms.config.Config')
# load specific instance configurations
app.config.from_pyfile('config.py', silent=True)
else:
# load defaults from config provided with the application
app.config.from_object('incorporealcms.config.Config')
# load specific instance configurations
app.config.from_pyfile('config.py', silent=True)
if test_config:
app.config.from_mapping(test_config)
dictConfig(app.config['LOGGING'])

View File

@ -15,7 +15,7 @@ def extract_requires():
setup(
name='incorporeal-cms',
description='Flask project for running https://incorporeal.org.',
description='Flask project for running https://suou.net (and eventually others).',
url='https://git.incorporeal.org/bss/incorporeal-cms',
license='GPL3',
author='Brian S. Stephan',

13
tests/test_factory.py Normal file
View File

@ -0,0 +1,13 @@
"""Test basic configuration stuff."""
import os
from incorporealcms import create_app
HERE = os.path.dirname(os.path.abspath(__file__))
def test_config():
"""Test create_app without passing test config."""
instance_path = os.path.join(HERE, 'instance')
assert not create_app(instance_path=instance_path).testing
assert create_app(instance_path=instance_path, test_config={"TESTING": True}).testing