From ad8513f2f686e8b97ba0dd9fa2a80238dcbb2fe8 Mon Sep 17 00:00:00 2001 From: David Gwilliam Date: Thu, 19 Mar 2026 23:20:32 -0700 Subject: [PATCH] fix(tests): Correctly patch fetch functions in test_app.py - Patch instead of - Add missing patches for and in background threads - Prevent network I/O during tests --- tests/test_app.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/test_app.py b/tests/test_app.py index 942bc8f..acc94c6 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -69,9 +69,11 @@ class TestRunPipelineMode: """run_pipeline_mode() exits if no content can be fetched.""" with ( patch("engine.app.pipeline_runner.load_cache", return_value=None), + patch("engine.app.pipeline_runner.fetch_all_fast", return_value=[]), patch( "engine.app.pipeline_runner.fetch_all", return_value=([], None, None) - ), + ), # Mock background thread + patch("engine.app.pipeline_runner.save_cache"), # Prevent disk I/O patch("engine.effects.plugins.discover_plugins"), pytest.raises(SystemExit) as exc_info, ): @@ -86,6 +88,7 @@ class TestRunPipelineMode: "engine.app.pipeline_runner.load_cache", return_value=cached ) as mock_load, patch("engine.app.pipeline_runner.fetch_all") as mock_fetch, + patch("engine.app.pipeline_runner.fetch_all_fast"), patch("engine.app.pipeline_runner.DisplayRegistry.create") as mock_create, ): mock_display = Mock() @@ -109,7 +112,8 @@ class TestRunPipelineMode: def test_run_pipeline_mode_creates_display(self): """run_pipeline_mode() creates a display backend.""" with ( - patch("engine.app.load_cache", return_value=["item"]), + patch("engine.app.pipeline_runner.load_cache", return_value=["item"]), + patch("engine.app.pipeline_runner.fetch_all_fast", return_value=[]), patch("engine.app.DisplayRegistry.create") as mock_create, ): mock_display = Mock() @@ -134,7 +138,8 @@ class TestRunPipelineMode: sys.argv = ["mainline.py", "--display", "websocket"] with ( - patch("engine.app.load_cache", return_value=["item"]), + patch("engine.app.pipeline_runner.load_cache", return_value=["item"]), + patch("engine.app.pipeline_runner.fetch_all_fast", return_value=[]), patch("engine.app.DisplayRegistry.create") as mock_create, ): mock_display = Mock() @@ -163,6 +168,7 @@ class TestRunPipelineMode: return_value=(["poem"], None, None), ) as mock_fetch_poetry, patch("engine.app.pipeline_runner.fetch_all") as mock_fetch_all, + patch("engine.app.pipeline_runner.fetch_all_fast", return_value=[]), patch("engine.app.pipeline_runner.DisplayRegistry.create") as mock_create, ): mock_display = Mock() @@ -187,6 +193,7 @@ class TestRunPipelineMode: """run_pipeline_mode() discovers available effect plugins.""" with ( patch("engine.app.pipeline_runner.load_cache", return_value=["item"]), + patch("engine.app.pipeline_runner.fetch_all_fast", return_value=[]), patch("engine.effects.plugins.discover_plugins") as mock_discover, patch("engine.app.pipeline_runner.DisplayRegistry.create") as mock_create, ):