def test_ensure_admins(tljh_dir, admins, expected_config): # --admin option called multiple times on the installer # creates a list of argument lists. installer.ensure_admins(admins) config_path = installer.CONFIG_FILE with open(config_path, 'r') as f: config = yaml.load(f) # verify the list was flattened assert config['users']['admin'] == expected_config
def test_no_empty_flow(tmpdir): path = tmpdir.join("config.yaml") with path.open("w") as f: f.write("{}") # load empty config file with path.open("r") as f: config = yaml.load(f) # set a value config["key"] = "value" # write to a file with path.open("w") as f: yaml.dump(config, f) # verify that it didn't use compact '{}' flow-style with path.open("r") as f: content = f.read() assert content.strip() == "key: value"
c.JupyterHub.spawner_class = UserCreatingSpawner # leave users running when the Hub restarts c.JupyterHub.cleanup_servers = False # Use a high port so users can try this on machines with a JupyterHub already present c.JupyterHub.hub_port = 15001 c.ConfigurableHTTPProxy.should_start = False c.ConfigurableHTTPProxy.api_url = 'http://127.0.0.1:15002' c.SystemdSpawner.extra_paths = [os.path.join(USER_ENV_PREFIX, 'bin')] c.SystemdSpawner.default_shell = '/bin/bash' # Drop the '-singleuser' suffix present in the default template c.SystemdSpawner.unit_name_template = 'jupyter-{USERNAME}' config_overrides_path = os.path.join(CONFIG_DIR, 'config.yaml') if os.path.exists(config_overrides_path): with open(config_overrides_path) as f: config_overrides = yaml.load(f) else: config_overrides = {} configurer.apply_config(config_overrides, c) # Load arbitrary .py config files if they exist. # This is our escape hatch extra_configs = sorted( glob(os.path.join(CONFIG_DIR, 'jupyterhub_config.d', '*.py'))) for ec in extra_configs: load_subconfig(ec)