Пример #1
0
def test_ssh_host_override_from_config(mock_file, mock_exists, dvc, config,
                                       expected_host):
    tree = SSHTree(dvc, config)

    mock_exists.assert_called_with(SSHTree.ssh_config_filename())
    mock_file.assert_called_with(SSHTree.ssh_config_filename())
    assert tree.path_info.host == expected_host
Пример #2
0
def test_ssh_allow_agent(mock_file, mock_exists, dvc, config,
                         expected_allow_agent):
    tree = SSHTree(dvc, config)

    mock_exists.assert_called_with(SSHTree.ssh_config_filename())
    mock_file.assert_called_with(SSHTree.ssh_config_filename())
    assert tree.allow_agent == expected_allow_agent
Пример #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 = SSHTree(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 = SSHTree(dvc, config)
    assert tree.path_info == url
Пример #4
0
def test_hardlink_optimization(dvc, tmp_dir, ssh):
    tree = SSHTree(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)
Пример #5
0
def test_no_path(dvc):
    config = {"url": "ssh://127.0.0.1"}
    tree = SSHTree(dvc, config)
    assert tree.path_info.path == ""
Пример #6
0
def test_ssh_gss_auth(mock_file, mock_exists, dvc, config, expected_gss_auth):
    tree = SSHTree(dvc, config)

    mock_exists.assert_called_with(SSHTree.ssh_config_filename())
    mock_file.assert_called_with(SSHTree.ssh_config_filename())
    assert tree.gss_auth == expected_gss_auth
Пример #7
0
def test_ssh_keyfile(mock_file, mock_exists, dvc, config, expected_keyfile):
    tree = SSHTree(dvc, config)

    mock_exists.assert_called_with(SSHTree.ssh_config_filename())
    mock_file.assert_called_with(SSHTree.ssh_config_filename())
    assert tree.keyfile == expected_keyfile
Пример #8
0
def test_ssh_port(mock_file, mock_exists, dvc, config, expected_port):
    tree = SSHTree(dvc, config)

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