forked from p15670423/monkey
island: Expand environment variables in data_dir
This commit is contained in:
parent
0ab20d558b
commit
c761dba030
|
@ -11,8 +11,9 @@ from monkey_island.cc.server_utils.consts import (
|
|||
|
||||
class IslandConfigOptions:
|
||||
def __init__(self, config_contents: dict):
|
||||
self.data_dir = os.path.expanduser(config_contents.get("data_dir", DEFAULT_DATA_DIR))
|
||||
|
||||
self.data_dir = os.path.expandvars(
|
||||
os.path.expanduser(config_contents.get("data_dir", DEFAULT_DATA_DIR))
|
||||
)
|
||||
self.log_level = config_contents.get("log_level", DEFAULT_LOG_LEVEL)
|
||||
|
||||
self.start_mongodb = config_contents.get(
|
||||
|
|
|
@ -52,3 +52,12 @@ def test_island_config_options__data_dir_expanduser(monkeypatch, tmpdir):
|
|||
options = IslandConfigOptions({"data_dir": f"~/{DATA_DIR_NAME}"})
|
||||
|
||||
assert options.data_dir == os.path.join(tmpdir, DATA_DIR_NAME)
|
||||
|
||||
|
||||
def test_island_config_options__data_dir_expandvars(monkeypatch, tmpdir):
|
||||
set_home_env(monkeypatch, tmpdir)
|
||||
DATA_DIR_NAME = "test_data_dir"
|
||||
|
||||
options = IslandConfigOptions({"data_dir": f"$HOME/{DATA_DIR_NAME}"})
|
||||
|
||||
assert options.data_dir == os.path.join(tmpdir, DATA_DIR_NAME)
|
||||
|
|
Loading…
Reference in New Issue