diff --git a/inventory_provider/__init__.py b/inventory_provider/__init__.py index ed7d1c17db0e309c8e30748575f07bb878ace8fa..3307321ecbd8f748dc0d5ea584c6ff479b00cdbe 100644 --- a/inventory_provider/__init__.py +++ b/inventory_provider/__init__.py @@ -39,11 +39,6 @@ def create_app(): from inventory_provider.routes import poller app.register_blueprint(poller.routes, url_prefix='/poller') - if "ENABLE_TESTING_ROUTES" in os.environ: - from inventory_provider.routes import testing - app.register_blueprint(testing.routes, url_prefix='/testing') - logging.warning('DANGER!!! testing routes enabled') - logging.info("initializing Flask with config from: %r" % os.environ["SETTINGS_FILENAME"]) app.config.from_envvar("SETTINGS_FILENAME") @@ -56,6 +51,11 @@ def create_app(): "config file '%s' not found" % app.config["INVENTORY_PROVIDER_CONFIG_FILENAME"]) + if app.config.get('ENABLE_TESTING_ROUTES', False): + from inventory_provider.routes import testing + app.register_blueprint(testing.routes, url_prefix='/testing') + logging.warning('DANGER!!! testing routes enabled') + from inventory_provider import config with open(app.config["INVENTORY_PROVIDER_CONFIG_FILENAME"]) as f: # test the config file can be loaded