forked from p15670423/monkey
Refactored IslandConfigOptions tests to be test per option, rather than based on code workflow branches
This commit is contained in:
parent
d52e80a3f3
commit
0248a6e281
|
@ -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
|
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():
|
def test_island_config_options__data_dir():
|
||||||
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_STANDARD)
|
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_SPECIFIED)
|
||||||
assert not options.start_mongodb
|
|
||||||
assert options.data_dir == "/tmp"
|
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
|
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)
|
options = IslandConfigOptions(TEST_CONFIG_FILE_CONTENTS_NO_STARTMONGO)
|
||||||
assert options.start_mongodb == DEFAULT_START_MONGO_DB
|
assert options.start_mongodb == DEFAULT_START_MONGO_DB
|
||||||
|
|
Loading…
Reference in New Issue