diff --git a/src/maildirclean/filedir.py b/src/maildirclean/filedir.py new file mode 100644 index 0000000..9fc8845 --- /dev/null +++ b/src/maildirclean/filedir.py @@ -0,0 +1,14 @@ +"""Module containing functionality to interact with the filesystem""" + +import os +from pathlib import Path + + +def delete_files(file_list: list[str | Path]): + """Delete all files in the provided file list + + Args: + file_list: List of file paths as either strings or Path + """ + for file in file_list: + os.remove(file) diff --git a/tests/test_filedir.py b/tests/test_filedir.py new file mode 100644 index 0000000..b369626 --- /dev/null +++ b/tests/test_filedir.py @@ -0,0 +1,10 @@ +from fixtures import * +from maildirclean.filedir import delete_files + + +def test_delete_files(sample_email_dir): + file_list = list(Path(sample_email_dir).glob("*")) + delete_files(file_list) + + for file in file_list: + assert not Path(file).is_file()