Added tests

This commit is contained in:
GeorgianaElena
2019-07-16 20:18:45 +03:00
parent f653d48b87
commit b4b37d84cc
4 changed files with 66 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
Unit test functions in installer.py
"""
import os
import pytest
from tljh import installer
from tljh.yaml import yaml
@@ -21,10 +22,17 @@ def test_ensure_config_yaml(tljh_dir):
# verify that old config doesn't exist
assert not os.path.exists(os.path.join(tljh_dir, 'config.yaml'))
def test_ensure_admins(tljh_dir):
@pytest.mark.parametrize(
"admins, expected_config",
[
([['a1'], ['a2'], ['a3']], ['a1', 'a2', 'a3']),
([['a1:p1'], ['a2']], ['a1', 'a2']),
],
)
def test_ensure_admins(tljh_dir, admins, expected_config):
# --admin option called multiple times on the installer
# creates a list of argument lists.
admins = [['a1'], ['a2'], ['a3']]
installer.ensure_admins(admins)
config_path = installer.CONFIG_FILE
@@ -32,4 +40,4 @@ def test_ensure_admins(tljh_dir):
config = yaml.load(f)
# verify the list was flattened
assert config['users']['admin'] == ['a1', 'a2', 'a3']
assert config['users']['admin'] == expected_config