Refactored IslandConfigOptions tests to be test per option, rather than based on code workflow branches

This commit is contained in:
VakarisZ 2021-05-24 14:25:22 +03:00
parent d52e80a3f3
commit 0248a6e281
1 changed files with 28 additions and 7 deletions

View File

@ -1,18 +1,39 @@
from monkey_island.cc.server_utils.consts import DEFAULT_LOG_LEVEL, DEFAULT_START_MONGO_DB
from monkey_island.cc.server_utils.consts import (
DEFAULT_DATA_DIR,
DEFAULT_LOG_LEVEL,
DEFAULT_START_MONGO_DB,
)
from monkey_island.setup.island_config_options import IslandConfigOptions
TEST_CONFIG_FILE_CONTENTS_STANDARD = {"data_dir": "/tmp", "mongodb": {"start_mongodb": False}}
TEST_CONFIG_FILE_CONTENTS_SPECIFIED = {
"data_dir": "/tmp",
"log_level": "test",
"mongodb": {"start_mongodb": False},
}
TEST_CONFIG_FILE_CONTENTS_NO_STARTMONGO = {"data_dir": "/tmp", "mongodb": {}}
TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED = {}
TEST_CONFIG_FILE_CONTENTS_NO_STARTMONGO = {"mongodb": {}}
def test_island_config_options__standard():
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_STANDARD)
assert not options.start_mongodb
def test_island_config_options__data_dir():
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_SPECIFIED)
assert options.data_dir == "/tmp"
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_UNSPECIFIED)
assert options.data_dir == DEFAULT_DATA_DIR
def test_island_config_options__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__no_starmongo():
def test_island_config_options__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