예제 #1
0
def test_databricks_params_token(get_config):
    get_config.return_value = DatabricksConfig.from_token("host", "mytoken", insecure=False)
    params = databricks_utils.get_databricks_host_creds()
    assert params.host == "host"
    assert params.token == "mytoken"
    assert not params.ignore_tls_verification
예제 #2
0
def test_databricks_params_user_password(get_config):
    get_config.return_value = DatabricksConfig.from_password("host", "user", "pass", insecure=False)
    params = databricks_utils.get_databricks_host_creds()
    assert params.host == "host"
    assert params.username == "user"
    assert params.password == "pass"
예제 #3
0
 def test_is_valid(self):
     config = DatabricksConfig.from_password(TEST_HOST, TEST_USER,
                                             TEST_PASSWORD)
     assert config.is_valid
     config = DatabricksConfig.from_token(TEST_HOST, TEST_TOKEN)
     assert config.is_valid
예제 #4
0
 def get_config(self):
     return DatabricksConfig.from_password("host", "user", "pass", insecure=False)
예제 #5
0
 def wrapper(test, *args, **kwargs):
     config = DatabricksConfig.from_token('test-host', 'test-token')
     update_and_persist_config(DEFAULT_SECTION, config)
     config = DatabricksConfig.from_token('test-host-2', 'test-token-2')
     update_and_persist_config(TEST_PROFILE, config)
     return test(*args, **kwargs)
예제 #6
0
 def test_is_valid_with_password(self):
     config = DatabricksConfig.from_password(TEST_HOST, TEST_USER,
                                             TEST_PASSWORD)
     assert config.is_valid_with_password
     assert not config.is_valid_with_token
예제 #7
0
 def test_from_token(self):
     config = DatabricksConfig.from_token(TEST_HOST, TEST_TOKEN)
     assert config.host == TEST_HOST
     assert config.token == TEST_TOKEN
예제 #8
0
 def get_config(self):
     return DatabricksConfig.from_token("Override", "Token!")
예제 #9
0
 def get_config(self):  # pylint: disable=unused-argument
     config = DatabricksConfig(host, None, None, token, False)
     if config.is_valid:
         return config
     return None
예제 #10
0
def test_databricks_params_custom_profile(get_config_for_profile):
    get_config_for_profile.return_value = \
        DatabricksConfig("host", "user", "pass", None, insecure=True)
    params = rest_utils.get_databricks_http_request_kwargs_or_fail("profile")
    assert params['verify'] is False
    get_config_for_profile.assert_called_with("profile")
예제 #11
0
def test_databricks_params_no_verify(get_config):
    get_config.return_value = \
        DatabricksConfig("host", "user", "pass", None, insecure=True)
    params = rest_utils.get_databricks_http_request_kwargs_or_fail()
    assert params['verify'] is False
예제 #12
0
def _configure_cli_token(profile, insecure):
    config = get_config_for_profile(profile)
    host = click.prompt(PROMPT_HOST, default=config.host, type=_DbfsHost())
    token = click.prompt(PROMPT_TOKEN, default=config.token)
    new_config = DatabricksConfig.from_token(host, token, insecure)
    update_and_persist_config(profile, new_config)
예제 #13
0
import shutil
import tempfile
import unittest
from uuid import uuid4

from click.testing import CliRunner
from cookiecutter.main import cookiecutter
from databricks_cli.configure.provider import DatabricksConfig
from path import Path
from retry import retry

CICD_TEMPLATES_URI = "https://github.com/databrickslabs/cicd-templates.git"
TEST_HOST = "https:/dbx.cloud.databricks.com"
TEST_TOKEN = "dapiDBXTEST"

test_dbx_config = DatabricksConfig.from_token(TEST_HOST, TEST_TOKEN)


@retry(tries=10, delay=5, backoff=5)
def initialize_cookiecutter(project_name):
    cookiecutter(CICD_TEMPLATES_URI, no_input=True, extra_context={"project_name": project_name})


def invoke_cli_runner(*args, **kwargs):
    """
    Helper method to invoke the CliRunner while asserting that the exit code is actually 0.
    """
    expected_error = kwargs.pop("expected_error") if kwargs.get("expected_error") else None

    res = CliRunner().invoke(*args, **kwargs)
def test_databricks_params_no_verify(get_config):
    get_config.return_value = \
        DatabricksConfig("host", "user", "pass", None, insecure=True)
    params = databricks_utils.get_databricks_host_creds()
    assert params.ignore_tls_verification
예제 #15
0
 def test_from_password(self):
     config = DatabricksConfig.from_password(TEST_HOST, TEST_USER,
                                             TEST_PASSWORD)
     assert config.host == TEST_HOST
     assert config.username == TEST_USER
     assert config.password == TEST_PASSWORD
예제 #16
0
def test_get_config_throw_exception_if_profile_invalid():
    invalid_config = DatabricksConfig.from_token(None, None)
    update_and_persist_config(DEFAULT_SECTION, invalid_config)
    with pytest.raises(InvalidConfigurationError):
        get_config()
예제 #17
0
 def test_is_valid_with_token(self):
     config = DatabricksConfig.from_token(TEST_HOST, TEST_TOKEN)
     assert not config.is_valid_with_password
     assert config.is_valid_with_token
예제 #18
0
 def get_config(self):
     return DatabricksConfig("host", "user", "pass", None, insecure=False)
예제 #19
0
def configure(version):
    profile = get_profile_from_context()
    config = ProfileConfigProvider(profile).get_config() if profile else get_config()
    new_config = config or DatabricksConfig.empty()
    new_config.jobs_api_version = version
    update_and_persist_config(profile, new_config)