WIP
This commit is contained in:
@@ -215,8 +215,10 @@ class TestAsyncProcessingService:
|
||||
|
||||
def test_cleanup_orphan_files(self, async_service, mock_db):
|
||||
"""Test cleanup of orphan files."""
|
||||
# Create an orphan file
|
||||
# Create the async upload directory
|
||||
temp_dir = async_service._async_config.temp_upload_dir
|
||||
temp_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
orphan_file = temp_dir / "orphan-request.pdf"
|
||||
orphan_file.write_bytes(b"orphan content")
|
||||
|
||||
@@ -228,7 +230,13 @@ class TestAsyncProcessingService:
|
||||
# Mock database to say file doesn't exist
|
||||
mock_db.get_request.return_value = None
|
||||
|
||||
count = async_service._cleanup_orphan_files()
|
||||
# Mock the storage helper to return the same directory as the fixture
|
||||
with patch("inference.web.services.async_processing.get_storage_helper") as mock_storage:
|
||||
mock_helper = MagicMock()
|
||||
mock_helper.get_uploads_base_path.return_value = temp_dir
|
||||
mock_storage.return_value = mock_helper
|
||||
|
||||
count = async_service._cleanup_orphan_files()
|
||||
|
||||
assert count == 1
|
||||
assert not orphan_file.exists()
|
||||
|
||||
Reference in New Issue
Block a user