Example #1
0
def test_remote_dot_not_delete():
    """Test do not delete missing local files on remote end."""
    normal_files = ("bar", "bis")  # just to add noise
    for f in normal_files:
        os.open(join(LOCAL_FOLDER, f), os.O_CREAT)
        os.open(join(REMOTE_PATH, f), os.O_CREAT)

    normal_dir = "dir"
    os.mkdir(join(LOCAL_FOLDER, normal_dir))

    remote_only = ("remote", "only")  # just to add noise
    for f in remote_only:
        os.open(join(REMOTE_PATH, f), os.O_CREAT)

    remote_dir = "remote_dir"
    os.mkdir(join(REMOTE_PATH, remote_dir))

    _sync(delete=False)

    local = set(file_tree(LOCAL_FOLDER)[LOCAL_FOLDER_NAME].keys())
    remote = set(file_tree(REMOTE_PATH)[REMOTE_FOLDER].keys())
    normal_files = set(normal_files)
    remote_only = set(remote_only)

    assert local < remote
    assert normal_files < remote
    assert normal_dir in remote
    assert remote_only < remote
    assert remote_dir in remote
    assert remote_dir not in local
    assert not remote_only & local
Example #2
0
def _sync(password=False,
          fix=False,
          exclude=None,
          ssh_agent=False,
          delete=True):
    """Launch sync and do basic comparison of dir trees."""
    if not password:
        remote = '[email protected]:' + '/' + REMOTE_FOLDER
    else:
        remote = 'test:[email protected]:' + '/' + REMOTE_FOLDER

    sync = SFTPClone(LOCAL_FOLDER,
                     remote,
                     port=2222,
                     fix_symlinks=fix,
                     identity_files=[t_path("id_rsa")],
                     exclude_file=exclude,
                     ssh_agent=ssh_agent,
                     delete=delete)
    sync.run()

    if not exclude and delete:
        # check the directory trees
        assert \
            file_tree(
                LOCAL_FOLDER
            )[LOCAL_FOLDER_NAME] == file_tree(
                REMOTE_PATH
            )[REMOTE_FOLDER]
def test_remote_dot_not_delete():
    """Test do not delete missing local files on remote end."""
    normal_files = ("bar", "bis")  # just to add noise
    for f in normal_files:
        os.open(join(LOCAL_FOLDER, f), os.O_CREAT)
        os.open(join(REMOTE_PATH, f), os.O_CREAT)

    normal_dir = "dir"
    os.mkdir(join(LOCAL_FOLDER, normal_dir))

    remote_only = ("remote", "only")  # just to add noise
    for f in remote_only:
        os.open(join(REMOTE_PATH, f), os.O_CREAT)

    remote_dir = "remote_dir"
    os.mkdir(join(REMOTE_PATH, remote_dir))

    _sync(delete=False)

    local = set(file_tree(LOCAL_FOLDER)[LOCAL_FOLDER_NAME].keys())
    remote = set(file_tree(REMOTE_PATH)[REMOTE_FOLDER].keys())
    normal_files = set(normal_files)
    remote_only = set(remote_only)

    assert local < remote
    assert normal_files < remote
    assert normal_dir in remote
    assert remote_only < remote
    assert remote_dir in remote
    assert remote_dir not in local
    assert not remote_only & local
def _sync(
        password=False, fix=False,
        exclude=None, ssh_agent=False,
        delete=True

):
    """Launch sync and do basic comparison of dir trees."""
    if not password:
        remote = '[email protected]:' + '/' + REMOTE_FOLDER
    else:
        remote = 'test:[email protected]:' + '/' + REMOTE_FOLDER

    sync = SFTPClone(
        LOCAL_FOLDER,
        remote,
        port=2222,
        fix_symlinks=fix,
        identity_files=[t_path("id_rsa")],
        exclude_file=exclude,
        ssh_agent=ssh_agent,
        delete=delete
    )
    sync.run()

    if not exclude and delete:
        # check the directory trees
        assert \
            file_tree(
                LOCAL_FOLDER
            )[LOCAL_FOLDER_NAME] == file_tree(
                REMOTE_PATH
            )[REMOTE_FOLDER]
def _sync_argv(argv):
    """Launch the module's main with given argv and check the result."""
    main(argv)

    assert \
        file_tree(
            LOCAL_FOLDER
        )[LOCAL_FOLDER_NAME] == file_tree(
            REMOTE_PATH
        )[REMOTE_FOLDER]
Example #6
0
def _sync_argv(argv):
    """Launch the module's main with given argv and check the result."""
    argv.append("-o")  # allow unknown hosts
    main(argv)

    assert \
        file_tree(
            LOCAL_FOLDER
        )[LOCAL_FOLDER_NAME] == file_tree(
            REMOTE_PATH
        )[REMOTE_FOLDER]
def _sync_argv(argv):
    """Launch the module's main with given argv and check the result."""
    argv.append("-o")  # allow unknown hosts
    main(argv)

    assert \
        file_tree(
            LOCAL_FOLDER
        )[LOCAL_FOLDER_NAME] == file_tree(
            REMOTE_PATH
        )[REMOTE_FOLDER]
Example #8
0
def test_remote_tilde_home():
    """Test tilde expansion on remote end."""
    normal_files = ("bar", "bis")  # just to add noise
    for f in normal_files:
        os.open(join(LOCAL_FOLDER, f), os.O_CREAT)
        os.open(join(REMOTE_PATH, f), os.O_CREAT)

    sync = SFTPClone(
        LOCAL_FOLDER,
        remote_url='[email protected]:' + '~' + REMOTE_FOLDER,
        port=2222,
        identity_files=[t_path("id_rsa"), ]
    )
    sync.run()

    assert file_tree(LOCAL_FOLDER)[LOCAL_FOLDER_NAME] == file_tree(REMOTE_PATH)[REMOTE_FOLDER]