about summary refs log tree commit diff
path: root/uploader
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2025-04-11 14:52:12 -0500
committerFrederick Muriuki Muriithi2025-04-11 14:52:12 -0500
commit774a0af9db439f50421a47249c57e5a0a6932301 (patch)
tree698ab3ead5c2e9eb5182b6d006f637752bf7de3b /uploader
parentdd2b36c5a3427c58df0cee332bd4661a3ceb0b4d (diff)
downloadgn-uploader-774a0af9db439f50421a47249c57e5a0a6932301.tar.gz
Update application initialisation to allow config updates for tests.
Diffstat (limited to 'uploader')
-rw-r--r--uploader/__init__.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/uploader/__init__.py b/uploader/__init__.py
index 734bdcd..e25fc5b 100644
--- a/uploader/__init__.py
+++ b/uploader/__init__.py
@@ -8,7 +8,7 @@ from flask import Flask, request
 from flask_session import Session
 from cachelib import FileSystemCache
 
-from gn_libs import jobs
+from gn_libs import jobs as gnlibs_jobs
 
 from uploader.oauth2.client import user_logged_in, authserver_authorise_uri
 
@@ -54,9 +54,15 @@ def setup_logging(app: Flask) -> Flask:
     return __log_gunicorn__(app) if bool(software) else __log_dev__(app)
 
 
-def create_app():
-    """The application factory"""
+def create_app(config: dir):
+    """The application factory.
+
+    config: dict
+      Useful to override settings in the settings files and environment
+      especially in environments such as testing."""
     app = Flask(__name__)
+
+    ### BEGIN: Application configuration
     app.config.from_pyfile(
         Path(__file__).parent.joinpath("default_settings.py"))
     if "UPLOADER_CONF" in os.environ:
@@ -71,6 +77,8 @@ def create_app():
         if secretsfile.exists():
             # Silently ignore secrets if the file does not exist.
             app.config.from_pyfile(secretsfile)
+    app.config.update(config) # Override everything with passed in config
+    ### END: Application configuration
 
     app.config["SESSION_CACHELIB"] = FileSystemCache(
         cache_dir=Path(app.config["SESSION_FILESYSTEM_CACHE_PATH"]).absolute(),
@@ -96,5 +104,5 @@ def create_app():
     app.register_blueprint(speciesbp, url_prefix="/species")
 
     register_error_handlers(app)
-    jobs.init_app(app)
+    gnlibs_jobs.init_app(app)
     return app