Пример #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}"
Пример #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}"
Пример #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}'
Пример #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
Пример #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}"
Пример #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}"
Пример #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}'
Пример #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"]
Пример #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"])
Пример #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']
Пример #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'])
Пример #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"])
Пример #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'])
Пример #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
Пример #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
Пример #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