agent: Test filter_files() with multiple filters
This commit is contained in:
parent
30f88ca319
commit
bfa640444e
|
@ -4,7 +4,7 @@ from infection_monkey.utils.dir_utils import (
|
|||
get_all_regular_files_in_directory,
|
||||
)
|
||||
|
||||
FILES = ["file.jpg.zip", "file.xyz", "1.tar", "2.tgz"]
|
||||
FILES = ["file.jpg.zip", "file.xyz", "1.tar", "2.tgz", "2.png", "2.mpg"]
|
||||
SUBDIRS = ["subdir1", "subdir2"]
|
||||
|
||||
|
||||
|
@ -70,6 +70,18 @@ def test_filter_files__all_true(tmp_path):
|
|||
assert sorted(filtered_files) == expected_return_value
|
||||
|
||||
|
||||
def test_filter_files__multiple_filters(tmp_path):
|
||||
files = add_files_to_dir(tmp_path)
|
||||
expected_return_value = sorted(files[4:6])
|
||||
|
||||
files_in_dir = get_all_regular_files_in_directory(tmp_path)
|
||||
filtered_files = filter_files(
|
||||
files_in_dir, [lambda f: f.name.startswith("2"), lambda f: f.name.endswith("g")]
|
||||
)
|
||||
|
||||
assert sorted(filtered_files) == expected_return_value
|
||||
|
||||
|
||||
def test_file_extension_filter(tmp_path):
|
||||
valid_extensions = {".zip", ".xyz"}
|
||||
|
||||
|
|
Loading…
Reference in New Issue