From f2a2efc2a7d5f0844e2b566d9f981ba881e88cd2 Mon Sep 17 00:00:00 2001 From: Mike Salvatore Date: Mon, 7 Jun 2021 12:30:03 -0400 Subject: [PATCH] island: Remove redundant "test_island_config_options" from tests The file is named "test_island_config_options.py". Including "island_config_options" in every test/function name is reduntant. --- .../cc/setup/test_island_config_options.py | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/monkey/tests/unit_tests/monkey_island/cc/setup/test_island_config_options.py b/monkey/tests/unit_tests/monkey_island/cc/setup/test_island_config_options.py index df3c0dabd..79cd15f25 100644 --- a/monkey/tests/unit_tests/monkey_island/cc/setup/test_island_config_options.py +++ b/monkey/tests/unit_tests/monkey_island/cc/setup/test_island_config_options.py @@ -18,30 +18,28 @@ TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED = {} TEST_CONFIG_FILE_CONTENTS_NO_STARTMONGO = {"mongodb": {}} -def test_island_config_options__data_dir_specified(): - assert_island_config_options_data_dir_equals(TEST_CONFIG_FILE_CONTENTS_SPECIFIED, "/tmp") +def test_data_dir_specified(): + assert_data_dir_equals(TEST_CONFIG_FILE_CONTENTS_SPECIFIED, "/tmp") -def test_island_config_options__data_dir_uses_default(): - assert_island_config_options_data_dir_equals( - TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED, DEFAULT_DATA_DIR - ) +def test_data_dir_uses_default(): + assert_data_dir_equals(TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED, DEFAULT_DATA_DIR) -def test_island_config_options__data_dir_expanduser(monkeypatch, tmpdir): +def test_data_dir_expanduser(monkeypatch, tmpdir): set_home_env(monkeypatch, tmpdir) DATA_DIR_NAME = "test_data_dir" - assert_island_config_options_data_dir_equals( + assert_data_dir_equals( {"data_dir": os.path.join("~", DATA_DIR_NAME)}, os.path.join(tmpdir, DATA_DIR_NAME) ) -def test_island_config_options__data_dir_expandvars(monkeypatch, tmpdir): +def test_data_dir_expandvars(monkeypatch, tmpdir): set_home_env(monkeypatch, tmpdir) DATA_DIR_NAME = "test_data_dir" - assert_island_config_options_data_dir_equals( + assert_data_dir_equals( {"data_dir": os.path.join("$HOME", DATA_DIR_NAME)}, os.path.join(tmpdir, DATA_DIR_NAME) ) @@ -50,26 +48,26 @@ def set_home_env(monkeypatch, tmpdir): monkeypatch.setenv("HOME", str(tmpdir)) -def assert_island_config_options_data_dir_equals(config_file_contents, expected_data_dir): +def assert_data_dir_equals(config_file_contents, expected_data_dir): assert_island_config_option_equals(config_file_contents, "data_dir", expected_data_dir) -def assert_island_config_option_equals(config_file_contents, option_name, expected_value): - options = IslandConfigOptions(config_file_contents) - assert getattr(options, option_name) == expected_value - - -def test_island_config_options__log_level(): +def test_log_level(): options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_SPECIFIED) assert options.log_level == "test" options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED) assert options.log_level == DEFAULT_LOG_LEVEL -def test_island_config_options__mongodb(): +def test_mongodb(): options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_SPECIFIED) assert not options.start_mongodb options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED) assert options.start_mongodb == DEFAULT_START_MONGO_DB options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_NO_STARTMONGO) assert options.start_mongodb == DEFAULT_START_MONGO_DB + + +def assert_island_config_option_equals(config_file_contents, option_name, expected_value): + options = IslandConfigOptions(config_file_contents) + assert getattr(options, option_name) == expected_value