From ab009e4f59f98679cf421594fb856c7d2a9512f0 Mon Sep 17 00:00:00 2001 From: "Brian S. Stephan" Date: Sat, 7 Mar 2020 19:37:02 -0600 Subject: [PATCH] reorder config imports for more specific overrides --- incorporealcms/__init__.py | 11 +++++------ setup.py | 2 +- tests/test_factory.py | 13 +++++++++++++ 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 tests/test_factory.py diff --git a/incorporealcms/__init__.py b/incorporealcms/__init__.py index d103b2a..cf6a7a4 100644 --- a/incorporealcms/__init__.py +++ b/incorporealcms/__init__.py @@ -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']) diff --git a/setup.py b/setup.py index c419caa..0138660 100644 --- a/setup.py +++ b/setup.py @@ -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', diff --git a/tests/test_factory.py b/tests/test_factory.py new file mode 100644 index 0000000..92ba443 --- /dev/null +++ b/tests/test_factory.py @@ -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