Exemplo n.º 1
0
def test_relative_path_env_home(config: str):
    home = '/Users/[email protected]'
    os.environ['DB_SHARD_HOME'] = home
    path = 'SomeFolder'
    w = Workspace('foo', config)
    p = w._adjust_remote_path(path)
    assert p == f'{home}/{path}'
def test_relative_path_env_home(config: str):
    home = "/Users/[email protected]"
    os.environ["DB_SHARD_HOME"] = home
    path = "SomeFolder"
    w = Workspace("foo", config)
    p = w._adjust_remote_path(path)
    assert p == f"{home}/{path}"
def test_relative_path_cfg_home(config: str):
    if os.environ.get("DB_SHARD_HOME"):
        del os.environ["DB_SHARD_HOME"]
    path = "SomeFolder"
    w = Workspace("bar", config)
    p = w._adjust_remote_path(path)
    assert p == f"/Users/[email protected]/{path}"
Exemplo n.º 4
0
def test_relative_path_cfg_home(config: str):
    if os.environ.get('DB_SHARD_HOME'):
        del os.environ['DB_SHARD_HOME']
    path = 'SomeFolder'
    w = Workspace('bar', config)
    p = w._adjust_remote_path(path)
    assert p == f'/Users/[email protected]/{path}'
def test_relative_path_cfg_and_env_home(config: str):
    home = "/Users/[email protected]"
    os.environ["DB_SHARD_HOME"] = home
    path = "SomeFolder"
    w = Workspace("bar", config)
    p = w._adjust_remote_path(path)
    # Environment should be preferred over the config.
    assert p == f"{home}/{path}"
Exemplo n.º 6
0
def test_relative_path_cfg_and_env_home(config: str):
    home = '/Users/[email protected]'
    os.environ['DB_SHARD_HOME'] = home
    path = 'SomeFolder'
    w = Workspace('bar', config)
    p = w._adjust_remote_path(path)
    # Environment should be preferred over the config.
    assert p == f'{home}/{path}'
Exemplo n.º 7
0
def test_relative_path_no_home(config: str):
    with pytest.raises(DatabricksError) as exc_info:
        if os.environ.get('DB_SHARD_HOME'):
            del os.environ['DB_SHARD_HOME']
        w = Workspace('foo', config)
        w._adjust_remote_path('foo/bar')

    assert exc_info.value.code == StatusCode.CONFIG_ERROR
Exemplo n.º 8
0
def test_relative_path_and_username_default(config: str):
    home = '/Users/[email protected]'
    if os.environ.get('DB_SHARD_HOME'):
        del os.environ['DB_SHARD_HOME']
    path = 'SomeFolder'
    w = Workspace('baz', config)
    p = w._adjust_remote_path(path)
    assert w.home == '/Users/[email protected]'
    assert p == f'{w.home}/{path}'
def test_relative_path_and_username_default(config: str):
    home = "/Users/[email protected]"
    if os.environ.get("DB_SHARD_HOME"):
        del os.environ["DB_SHARD_HOME"]
    path = "SomeFolder"
    w = Workspace("baz", config)
    p = w._adjust_remote_path(path)
    assert w.home == "/Users/[email protected]"
    assert p == f"{w.home}/{path}"
Exemplo n.º 10
0
def test_user_home_default(config):
    cfg = ConfigParser()
    cfg.read(config)
    section = cfg["has_user_not_home"]
    user = section["username"]
    w = Workspace(config=config, profile="has_user_not_home")
    assert w.home == f"/Users/{user}"
Exemplo n.º 11
0
def test_user_home_default(config):
    cfg = ConfigParser()
    cfg.read(config)
    section = cfg['has_user_not_home']
    user = section['username']
    w = Workspace(config=config, profile='has_user_not_home')
    assert w.home == f'/Users/{user}'
Exemplo n.º 12
0
def test_has_all_three(config):
    cfg = ConfigParser()
    cfg.read(config)
    section = cfg["bar"]

    w = Workspace("bar", config)
    assert w.home == section["home"]
    assert w.host == databricks._fix_host(section["host"])
    assert w.token == section["token"]
Exemplo n.º 13
0
def test_default(config_with_default):
    cfg = ConfigParser()
    cfg.read(config_with_default)
    default = cfg["DEFAULT"]

    w = Workspace(config=config_with_default)
    assert w.token == default["token"]
    assert w.home == default["home"]
    assert w.host == databricks._fix_host(default["host"])
Exemplo n.º 14
0
def test_has_all_three(config):
    cfg = ConfigParser()
    cfg.read(config)
    section = cfg['bar']

    w = Workspace('bar', config)
    assert w.home == section['home']
    assert w.host == databricks._fix_host(section['host'])
    assert w.token == section['token']
Exemplo n.º 15
0
def test_default(config_with_default):
    cfg = ConfigParser()
    cfg.read(config_with_default)
    default = cfg['DEFAULT']

    w = Workspace(config=config_with_default)
    assert w.token == default['token']
    assert w.home == default['home']
    assert w.host == databricks._fix_host(default['host'])
Exemplo n.º 16
0
def test_default_with_missing_home(config_with_default):
    cfg = ConfigParser()
    cfg.read(config_with_default)
    default = cfg["DEFAULT"]
    section = cfg["missing_home"]

    w = Workspace("missing_home", config_with_default)
    assert w.token == section["token"]
    assert w.home == default["home"]
    assert w.host == databricks._fix_host(section["host"])
Exemplo n.º 17
0
def test_default_with_missing_home(config_with_default):
    cfg = ConfigParser()
    cfg.read(config_with_default)
    default = cfg['DEFAULT']
    section = cfg['missing_home']

    w = Workspace('missing_home', config_with_default)
    assert w.token == section['token']
    assert w.home == default['home']
    assert w.host == databricks._fix_host(section['host'])
Exemplo n.º 18
0
def test_missing_section(config):
    with pytest.raises(DatabricksError) as exc_info:
        Workspace("nosuchsection", config)

    assert exc_info.value.code == StatusCode.CONFIG_ERROR
Exemplo n.º 19
0
def test_missing_home_and_token(config):
    with pytest.raises(DatabricksError) as exc_info:
        Workspace("empty", config)

    assert exc_info.value.code == StatusCode.CONFIG_ERROR
Exemplo n.º 20
0
def test_missing_host(config):
    with pytest.raises(DatabricksError) as exc_info:
        Workspace('missing_host', config)

    assert exc_info.value.code == StatusCode.CONFIG_ERROR