diff --git a/monkey/tests/monkey_island/mock_file_repository.py b/monkey/tests/monkey_island/mock_file_repository.py index f828cdd5a..e7dc76bc1 100644 --- a/monkey/tests/monkey_island/mock_file_repository.py +++ b/monkey/tests/monkey_island/mock_file_repository.py @@ -24,7 +24,7 @@ class MockFileRepository(IFileRepository): def delete_file(self, unsafe_file_name: str): pass - def delete_files_by_pattern(self, file_name_pattern: str): + def delete_files_by_regex(self, file_name_regex: str): pass def delete_all_files(self): diff --git a/monkey/tests/monkey_island/single_file_repository.py b/monkey/tests/monkey_island/single_file_repository.py index 66086f0f2..be9f896ba 100644 --- a/monkey/tests/monkey_island/single_file_repository.py +++ b/monkey/tests/monkey_island/single_file_repository.py @@ -24,8 +24,8 @@ class SingleFileRepository(IFileRepository): self._file = None self._file_name = "" - def delete_files_by_pattern(self, file_name_pattern: str): - if re.match(file_name_pattern, self._file_name): + def delete_files_by_regex(self, file_name_regex: re.Pattern): + if re.match(file_name_regex, self._file_name): self.delete_file("") def delete_all_files(self): diff --git a/monkey/tests/unit_tests/monkey_island/cc/repository/test_local_storage_file_repository.py b/monkey/tests/unit_tests/monkey_island/cc/repository/test_local_storage_file_repository.py index 03fa1f5ca..f088ee16e 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/repository/test_local_storage_file_repository.py +++ b/monkey/tests/unit_tests/monkey_island/cc/repository/test_local_storage_file_repository.py @@ -1,4 +1,5 @@ import io +import re from pathlib import Path from unittest.mock import Mock, patch @@ -145,12 +146,12 @@ def test_open_locked_file(tmp_path, monkeypatch): fss.open_file("locked_file.txt") -def test_delete_files_by_pattern(tmp_path): +def test_delete_files_by_regex(tmp_path): for filename in {"xyz-1.txt", "abc-2.txt", "pqr-3.txt", "abc-4.txt", "abc-5.pdf"}: (tmp_path / filename).touch() fss = LocalStorageFileRepository(tmp_path) - fss.delete_files_by_pattern("abc-*.txt") + fss.delete_files_by_regex(re.compile(r"^abc-[\w-]+.txt$")) files = {f.name for f in tmp_path.iterdir()} assert files == {"xyz-1.txt", "pqr-3.txt", "abc-5.pdf"}