mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
narrowing bulk_download stop service scope
This commit is contained in:
parent
12b0d735e7
commit
ff53563152
@ -143,8 +143,8 @@ class BulkDownloadService(BulkDownloadBase):
|
|||||||
|
|
||||||
def stop(self, *args, **kwargs):
|
def stop(self, *args, **kwargs):
|
||||||
"""Stop the bulk download service and delete the files in the bulk download folder."""
|
"""Stop the bulk download service and delete the files in the bulk download folder."""
|
||||||
# Get all the files in the bulk downloads folder
|
# Get all the files in the bulk downloads folder, only .zip files
|
||||||
files = self.__bulk_downloads_folder.glob("*")
|
files = self.__bulk_downloads_folder.glob("*.zip")
|
||||||
|
|
||||||
# Delete all the files
|
# Delete all the files
|
||||||
for file in files:
|
for file in files:
|
||||||
|
@ -319,7 +319,7 @@ def execute_handler_test_on_error(
|
|||||||
assert event_bus.events[1].payload["error"] == error.__str__()
|
assert event_bus.events[1].payload["error"] == error.__str__()
|
||||||
|
|
||||||
|
|
||||||
def test_delete(tmp_path: Path, monkeypatch: Any, mock_image_dto: ImageDTO, mock_invoker: Invoker):
|
def test_delete(tmp_path: Path):
|
||||||
"""Test that the delete method removes the bulk download file."""
|
"""Test that the delete method removes the bulk download file."""
|
||||||
|
|
||||||
bulk_download_service = BulkDownloadService(tmp_path)
|
bulk_download_service = BulkDownloadService(tmp_path)
|
||||||
@ -331,3 +331,21 @@ def test_delete(tmp_path: Path, monkeypatch: Any, mock_image_dto: ImageDTO, mock
|
|||||||
|
|
||||||
assert (tmp_path / "bulk_downloads").exists()
|
assert (tmp_path / "bulk_downloads").exists()
|
||||||
assert len(os.listdir(tmp_path / "bulk_downloads")) == 0
|
assert len(os.listdir(tmp_path / "bulk_downloads")) == 0
|
||||||
|
|
||||||
|
def test_stop(tmp_path: Path):
|
||||||
|
"""Test that the delete method removes the bulk download file."""
|
||||||
|
|
||||||
|
bulk_download_service = BulkDownloadService(tmp_path)
|
||||||
|
|
||||||
|
mock_file: Path = tmp_path / "bulk_downloads" / "test.zip"
|
||||||
|
mock_file.write_text("contents")
|
||||||
|
|
||||||
|
mock_dir: Path = tmp_path / "bulk_downloads" / "test"
|
||||||
|
mock_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
|
||||||
|
bulk_download_service.stop()
|
||||||
|
|
||||||
|
assert (tmp_path / "bulk_downloads").exists()
|
||||||
|
assert mock_dir.exists()
|
||||||
|
assert len(os.listdir(tmp_path / "bulk_downloads")) == 1
|
||||||
|
Loading…
Reference in New Issue
Block a user