Coverage for postrfp/web/mounts.py: 100%
14 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-22 21:34 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2025-10-22 21:34 +0000
1from postrfp import conf
3from postrfp.web.hooks import WebhookApp
4from .apps import TokenAuthenticationApp, BuyerApp, VendorApp, FsmApp, RefApp
7def build_app_mounts(session_factory, auth_policies: dict) -> dict:
8 """Build WSGI application mount dictionary from configuration.
10 Args:
11 session_factory: SQLAlchemy session factory
12 auth_policies: Dict mapping app types to auth policy instances
14 Returns:
15 Dict mapping paths to WSGI app instances
16 """
17 if conf.CONF is None:
18 raise Exception(
19 "--!!--postrfp not configured. Call utils.configure_postrfp()--"
20 )
22 # Define app configurations: (path_attr, app_class, auth_policy_key)
23 app_configs = [
24 ("app_path_auth", TokenAuthenticationApp, "auth"),
25 ("app_path_hooks", WebhookApp, "hooks"),
26 ("app_path_buyer", BuyerApp, "buyer"),
27 ("app_path_vendor", VendorApp, "vendor"),
28 ("app_path_fsm", FsmApp, "fsm"),
29 ("app_path_ref", RefApp, "ref"),
30 ]
32 mounts = {}
34 for path_attr, app_class, auth_key in app_configs:
35 path = getattr(conf.CONF, path_attr)
36 if path is not None:
37 app_instance = app_class(
38 session_factory=session_factory, auth_policy=auth_policies.get(auth_key)
39 )
40 mounts[path] = app_instance
42 return mounts