UT: Add tests for delete_files_by_pattern() in LocalStorageFileRepository

This commit is contained in:
Shreya Malviya 2022-09-28 16:21:09 +05:30
parent 6aae63f9fc
commit 885a907287
1 changed files with 11 additions and 0 deletions

View File

@ -143,3 +143,14 @@ def test_open_locked_file(tmp_path, monkeypatch):
with patch("builtins.open", Mock(side_effect=Exception())):
with pytest.raises(repository.RetrievalError):
fss.open_file("locked_file.txt")
def test_delete_files_by_pattern(tmp_path):
for filename in ["xyz-1.txt", "abc-2.txt", "pqr-3.txt", "abc-4.txt"]:
(tmp_path / filename).touch()
fss = LocalStorageFileRepository(tmp_path)
fss.delete_files_by_pattern("abc-*")
files = list(tmp_path.iterdir())
assert len(files) == 2