Exemplo n.º 1
0
def test_ssh_host_override_from_config(mock_file, mock_exists, dvc, config,
                                       expected_host):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.path_info.host == expected_host
Exemplo n.º 2
0
def test_hardlink_optimization(dvc, tmp_dir, ssh):
    tree = SSHRemoteTree(dvc, ssh.config)

    from_info = tree.path_info / "empty"
    to_info = tree.path_info / "link"

    with tree.open(from_info, "wb"):
        pass

    if os.name == "nt":
        link_path = "c:" + to_info.path.replace("/", "\\")
    else:
        link_path = to_info.path

    tree.hardlink(from_info, to_info)
    assert not System.is_hardlink(link_path)
Exemplo n.º 3
0
def test_url(dvc):
    user = "******"
    host = "123.45.67.89"
    port = 1234
    path = "/path/to/dir"

    # URL ssh://[user@]host.xz[:port]/path
    url = f"ssh://{user}@{host}:{port}{path}"
    config = {"url": url}

    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info == url

    # SCP-like URL ssh://[user@]host.xz:/absolute/path
    url = f"ssh://{user}@{host}:{path}"
    config = {"url": url}

    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info == url
Exemplo n.º 4
0
def test_no_path(dvc):
    config = {"url": "ssh://127.0.0.1"}
    tree = SSHRemoteTree(dvc, config)
    assert tree.path_info.path == ""
Exemplo n.º 5
0
def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.gss_auth == expected_gss_auth
Exemplo n.º 6
0
def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.keyfile == expected_keyfile
Exemplo n.º 7
0
def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
    tree = SSHRemoteTree(dvc, config)

    mock_exists.assert_called_with(SSHRemoteTree.ssh_config_filename())
    mock_file.assert_called_with(SSHRemoteTree.ssh_config_filename())
    assert tree.path_info.port == expected_port