test(tests): add global mocks and cleanup fixtures for improved test isolation and resource management

This commit is contained in:
2026-01-03 22:10:19 -06:00
parent 31525e2ede
commit 4e308e427a
8 changed files with 83 additions and 19 deletions

View File

@@ -93,7 +93,9 @@ async def test_app_shutdown_endpoint(mock_rns_minimal, temp_dir):
)
# Mock shutdown method to avoid actual exit
app_instance.shutdown = MagicMock(side_effect=asyncio.sleep(0))
from unittest.mock import AsyncMock
app_instance.shutdown = AsyncMock()
# Create a mock request
request = MagicMock()
@@ -108,10 +110,7 @@ async def test_app_shutdown_endpoint(mock_rns_minimal, temp_dir):
assert shutdown_handler is not None
# We need to patch sys.exit to avoid stopping the test runner
with (
patch("sys.exit"),
patch("asyncio.sleep", return_value=asyncio.sleep(0)),
):
with patch("sys.exit"):
response = await shutdown_handler(request)
assert response.status == 200
data = json.loads(response.body)