island: Add unit test for load_server_config()

This commit is contained in:
Mike Salvatore 2021-05-11 13:14:07 -04:00
parent f7bef76f39
commit 5847674d92
3 changed files with 31 additions and 0 deletions

View File

@ -46,3 +46,20 @@ def with_data_dir(environment_resources_dir):
@pytest.fixture(scope="session")
def with_data_dir_home(environment_resources_dir):
return os.path.join(environment_resources_dir, "server_config_with_data_dir_home.json")
@pytest.fixture(scope="session")
def server_config_resources_dir(resources_dir):
return os.path.join(resources_dir, "server_configs")
@pytest.fixture(scope="session")
def test_server_config(server_config_resources_dir):
return os.path.join(server_config_resources_dir, "test_server_config.json")
@pytest.fixture
def mock_home_env(monkeypatch, tmpdir):
monkeypatch.setenv("HOME", str(tmpdir))
return tmpdir

View File

@ -0,0 +1,10 @@
import os
from monkey_island import config_loader
def test_load_server_config_from_file(test_server_config, mock_home_env):
(data_dir, log_level) = config_loader.load_server_config(test_server_config)
assert data_dir == os.path.join(mock_home_env, ".monkey_island")
assert log_level == "NOTICE"

View File

@ -0,0 +1,4 @@
{
"data_dir": "~/.monkey_island",
"log_level": "NOTICE"
}