@@ -240,23 +240,26 @@ async def _fake_once():
240240
241241
242242async def test_prod_lifespan_warms_and_cancels_loop (monkeypatch , tmp_path ):
243- """Boot the app with LANGFLOW_PROD=true to cover the main.py prod wiring.
243+ """Boot the app under the prod deployment profile to cover the main.py prod wiring.
244244
245245 Startup runs the warm block; shutdown cancels the reconcile loop.
246246 """
247+ import langflow .main as main_mod
247248 from asgi_lifespan import LifespanManager
248249 from langflow .main import create_app
249250 from langflow .services .deps import get_db_service
250251 from lfx .services .manager import get_service_manager
251252
252253 db_path = tmp_path / "prod.db"
253- monkeypatch .setenv ("LANGFLOW_PROD" , "true" )
254+ # ``deployment_profile`` is owned by the preflight PR and not present on this branch,
255+ # so drive the prod branch by patching the profile check the lifespan calls.
256+ monkeypatch .setattr (main_mod , "is_prod_deployment" , lambda _settings : True )
254257 monkeypatch .setenv ("LANGFLOW_DATABASE_URL" , f"sqlite:///{ db_path } " )
255258 monkeypatch .setenv ("LANGFLOW_AUTO_LOGIN" , "true" )
256259 monkeypatch .setenv ("DO_NOT_TRACK" , "true" )
257260
258261 def _init ():
259- # Fresh service stack so settings.prod is re-read from the env above.
262+ # Fresh service stack booted from the env above.
260263 get_service_manager ().factories .clear ()
261264 get_service_manager ().services .clear ()
262265 app = create_app ()
@@ -279,6 +282,7 @@ def _init():
279282
280283async def test_prod_lifespan_survives_warm_failure (monkeypatch , tmp_path ):
281284 """A failure in warm_all during prod startup is logged, not fatal (except branch)."""
285+ import langflow .main as main_mod
282286 from asgi_lifespan import LifespanManager
283287 from langflow .main import create_app
284288 from langflow .services .deps import get_db_service
@@ -293,7 +297,8 @@ async def _boom_warm() -> None:
293297 monkeypatch .setattr (reconcile_mod , "warm_all" , _boom_warm )
294298
295299 db_path = tmp_path / "prod_fail.db"
296- monkeypatch .setenv ("LANGFLOW_PROD" , "true" )
300+ # Drive the prod branch via the profile check (see the sibling lifespan test).
301+ monkeypatch .setattr (main_mod , "is_prod_deployment" , lambda _settings : True )
297302 monkeypatch .setenv ("LANGFLOW_DATABASE_URL" , f"sqlite:///{ db_path } " )
298303 monkeypatch .setenv ("LANGFLOW_AUTO_LOGIN" , "true" )
299304 monkeypatch .setenv ("DO_NOT_TRACK" , "true" )
@@ -517,7 +522,9 @@ def test_deferred_host_resolves_db_when_not_prod(monkeypatch):
517522 from langflow .services import deps
518523
519524 monkeypatch .setattr (deps , "is_settings_service_initialized" , lambda : True )
520- monkeypatch .setattr (deps , "get_settings_service" , lambda : SimpleNamespace (settings = SimpleNamespace (prod = False )))
525+ monkeypatch .setattr (
526+ deps , "get_settings_service" , lambda : SimpleNamespace (settings = SimpleNamespace (deployment_profile = "dev" ))
527+ )
521528 host = DeferredWorkflowHost ()
522529 assert isinstance (host ._resolve (), LangflowWorkflowHost )
523530
@@ -531,7 +538,9 @@ def test_deferred_host_resolves_warm_when_prod(monkeypatch):
531538 from langflow .services import deps
532539
533540 monkeypatch .setattr (deps , "is_settings_service_initialized" , lambda : True )
534- monkeypatch .setattr (deps , "get_settings_service" , lambda : SimpleNamespace (settings = SimpleNamespace (prod = True )))
541+ monkeypatch .setattr (
542+ deps , "get_settings_service" , lambda : SimpleNamespace (settings = SimpleNamespace (deployment_profile = "prod" ))
543+ )
535544 host = DeferredWorkflowHost ()
536545 resolved = host ._resolve ()
537546 assert isinstance (resolved , WarmWorkflowHost )
0 commit comments