Ejemplo n.º 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'
Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 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')
Ejemplo n.º 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")
Ejemplo n.º 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'
Ejemplo n.º 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'
Ejemplo n.º 8
0
def test_missing_params():
    """Test deployment without any parameters at all.
    """
    dep = JupyterLabDeployment()
    assert dep.params is None
Ejemplo n.º 9
0
def test_filesystem_default_size():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['volume_size_gigabytes'] == 20
Ejemplo n.º 10
0
def test_default_cluster_namespace():
    dep = JupyterLabDeployment(params={"hostname": "kremvax.ru"})
    dep._validate_deployment_params()
    assert dep.params['kubernetes_cluster_namespace'] == 'default'
Ejemplo n.º 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"
Ejemplo n.º 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')
Ejemplo n.º 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
Ejemplo n.º 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