mirror of
https://github.com/jupyterhub/the-littlest-jupyterhub.git
synced 2025-12-18 21:54:05 +08:00
Added tests
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user