Add relevant tests and formatting

This commit is contained in:
Jean-Marc Alkazzi
2020-10-20 00:14:15 +02:00
committed by GeorgianaElena
parent 66cd578d75
commit f799206920
2 changed files with 37 additions and 14 deletions

View File

@@ -2,6 +2,7 @@
Test configurer
"""
from traitlets import Dict
import os
import sys
@@ -62,6 +63,22 @@ def apply_mock_config(overrides):
return c
def test_default_base_url():
"""
Test default JupyterHub base_url
"""
c = apply_mock_config({})
assert c.JupyterHub.base_url == '/'
def test_set_base_url():
"""
Test set JupyterHub base_url
"""
c = apply_mock_config({'base_url': '/custom-base'})
assert c.JupyterHub.base_url == '/custom-base'
def test_default_memory_limit():
"""
Test default per user memory limit
@@ -129,7 +146,7 @@ def test_auth_dummy():
assert c.JupyterHub.authenticator_class == 'dummyauthenticator.DummyAuthenticator'
assert c.DummyAuthenticator.password == 'test'
from traitlets import Dict
def test_user_groups():
"""
Test setting user groups
@@ -276,4 +293,3 @@ def test_auth_native():
})
assert c.JupyterHub.authenticator_class == 'nativeauthenticator.NativeAuthenticator'
assert c.NativeAuthenticator.open_signup == True

View File

@@ -61,6 +61,7 @@ def set_item_in_config(config, property_path, value):
return config_copy
def unset_item_from_config(config, property_path):
"""
Unset key at property_path in config & return new config.
@@ -105,6 +106,7 @@ def unset_item_from_config(config, property_path):
return config_copy
def add_item_to_config(config, property_path, value):
"""
Add an item to a list in config.
@@ -238,6 +240,7 @@ def remove_config_value(config_path, key_path, value):
with open(config_path, 'w') as f:
yaml.dump(config, f)
def check_hub_ready():
from .configurer import load_config
@@ -250,6 +253,7 @@ def check_hub_ready():
except:
return False
def reload_component(component):
"""
Reload a TLJH component.
@@ -392,13 +396,16 @@ def main(argv=None):
if args.action == 'show':
show_config(args.config_path)
elif args.action == 'set':
set_config_value(args.config_path, args.key_path, parse_value(args.value))
set_config_value(args.config_path, args.key_path,
parse_value(args.value))
elif args.action == 'unset':
unset_config_value(args.config_path, args.key_path)
elif args.action == 'add-item':
add_config_value(args.config_path, args.key_path, parse_value(args.value))
add_config_value(args.config_path, args.key_path,
parse_value(args.value))
elif args.action == 'remove-item':
remove_config_value(args.config_path, args.key_path, parse_value(args.value))
remove_config_value(args.config_path, args.key_path,
parse_value(args.value))
elif args.action == 'reload':
reload_component(args.component)
else: