示例#1
0
def test_explicit_cluster_namespace():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "kubernetes_cluster_namespace": "raskolnikov"
    })
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_namespace'] == 'raskolnikov'
示例#2
0
def test_filesystem_illegal_size():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "volume_size_gigabytes": -2
    })
    with pytest.raises(ValueError):
        dep._validate_deployment_params()
示例#3
0
def test_missing_hostname():
    """Test deployment parameters without a hostname.
    """
    dep = JupyterLabDeployment(params={})
    assert (dep)

    with pytest.raises(ValueError):
        dep._validate_deployment_params()
示例#4
0
def check_default_options():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "github_organization_whitelist": "nkvd"
    })
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert dep.params['dhparam_bits'] == 2048
    assert dep.params['session_db_url'] == ('sqlite:////home/jupyter' +
                                            '/jupyterhub.sqlite')
示例#5
0
def test_callback_url():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "github_organization_whitelist": "nkvd"
    })
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_callback_url'] == (
        "https://kremvax.ru/hub/oauth_callback")
示例#6
0
def test_github_organization_whitelist():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    with pytest.raises(KeyError):
        dep._normalize_params()
    dep.params['github_organization_whitelist'] = []
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == ''
    dep.params['github_organization_whitelist'] = ['nkvd']
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == 'nkvd'
    dep.params['github_organization_whitelist'] = ['nkvd', 'kgb']
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['github_organization_whitelist'] == 'nkvd,kgb'
示例#7
0
def test_filesystem_calculate_sizes():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "github_organization_whitelist": "nkvd"
    })
    dep._validate_deployment_params()
    dep._normalize_params()
    assert dep.params['volume_size'] == '20Gi'
    assert dep.params['nfs_volume_size'] == '19Gi'
    dep.params['volume_size_gigabytes'] = 1
    dep._normalize_params()
    assert dep.params['volume_size'] == '1Gi'
    assert dep.params['nfs_volume_size'] == '950Mi'
    dep.params['volume_size_gigabytes'] = 1392
    dep._normalize_params()
    assert dep.params['volume_size'] == '1392Gi'
    assert dep.params['nfs_volume_size'] == '1322Gi'
示例#8
0
def test_missing_params():
    """Test deployment without any parameters at all.
    """
    dep = JupyterLabDeployment()
    assert dep.params is None
示例#9
0
def test_filesystem_default_size():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['volume_size_gigabytes'] == 20
示例#10
0
def test_default_cluster_namespace():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_namespace'] == 'default'
示例#11
0
def test_explicit_cluster_name():
    dep = JupyterLabDeployment(params={"hostname": "westwing.ru"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_name'] == "westwing-ru"
示例#12
0
def test_empty_param_method():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep._empty_param('missing')
    assert not dep._empty_param('hostname')
示例#13
0
def test_enable_logging():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "github_organization_whitelist": "nkvd"
    })
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert not dep.enable_logging
    for l in [
            'rabbitmq_pan_password', 'rabbitmq_target_host',
            'rabbitmq_target_vhost', 'log_shipper_name', 'beats_key',
            'beats_ca', 'beats_cert'
    ]:
        dep.params[l] = 'da, tovarisch'
    dep._check_optional()
    assert dep.enable_logging
示例#14
0
def test_enable_firefly():
    dep = JupyterLabDeployment(params={
        "hostname": "kremvax.ru",
        "github_organization_whitelist": "nkvd"
    })
    dep._validate_deployment_params()
    dep._normalize_params()
    dep._check_optional()
    assert not dep.enable_firefly
    dep.params['firefly_admin_password'] = '******'
    dep._check_optional()
    assert dep.enable_firefly