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
This commit is contained in:
@@ -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,
|
||||
):
|
||||
|
||||
Reference in New Issue
Block a user