From db142859349fe88b04d805a6fa0544e3345cd437 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Wed, 12 May 2021 08:10:01 -0400 Subject: [PATCH] island: Add `dir_is_empty()` to clarify intent of `test_remove_pba_files()` --- .../cc/services/test_post_breach_files.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/monkey/tests/monkey_island/cc/services/test_post_breach_files.py b/monkey/tests/monkey_island/cc/services/test_post_breach_files.py index 7d3431cfd..cc1c80e1f 100644 --- a/monkey/tests/monkey_island/cc/services/test_post_breach_files.py +++ b/monkey/tests/monkey_island/cc/services/test_post_breach_files.py @@ -25,13 +25,14 @@ def test_remove_pba_files(): create_custom_pba_file("linux_file") create_custom_pba_file("windows_file") - custom_pda_dir_contents = os.listdir(PostBreachFilesService.get_custom_pba_directory()) - assert len(custom_pda_dir_contents) == 2 - + assert not dir_is_empty(PostBreachFilesService.get_custom_pba_directory()) PostBreachFilesService.remove_PBA_files() + assert dir_is_empty(PostBreachFilesService.get_custom_pba_directory()) - custom_pda_dir_contents = os.listdir(PostBreachFilesService.get_custom_pba_directory()) - assert len(custom_pda_dir_contents) == 0 + +def dir_is_empty(dir_path): + dir_contents = os.listdir(dir_path) + return len(dir_contents) == 0 @pytest.mark.skipif(os.name != "posix", reason="Tests Posix (not Windows) permissions.")