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
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_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}"
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_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}'
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}"
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}"