narrowing bulk_download stop service scope

This commit is contained in:
Stefan Tobler 2024-01-28 00:38:01 -05:00 committed by psychedelicious
parent 12b0d735e7
commit ff53563152
2 changed files with 21 additions and 3 deletions

View File

@ -143,8 +143,8 @@ class BulkDownloadService(BulkDownloadBase):
def stop(self, *args, **kwargs):
"""Stop the bulk download service and delete the files in the bulk download folder."""
# Get all the files in the bulk downloads folder
files = self.__bulk_downloads_folder.glob("*")
# Get all the files in the bulk downloads folder, only .zip files
files = self.__bulk_downloads_folder.glob("*.zip")
# Delete all the files
for file in files:

View File

@ -319,7 +319,7 @@ def execute_handler_test_on_error(
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."""
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 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