Ejemplo n.º 1
0
def test_create_symlink(tmpdir, presplit_dotfile):
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(presplit_dotfile[0])
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, *presplit_dotfile)
            link_dst = os.path.join(test_repo_dir, *presplit_dotfile)
            create_symlink(*presplit_dotfile)
            assert os.path.islink(link_path)
            assert os.readlink(link_path) == link_dst
Ejemplo n.º 2
0
def test_create_symlink(tmpdir, presplit_dotfile):
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(presplit_dotfile[0])
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, *presplit_dotfile)
            link_dst = os.path.join(test_repo_dir, *presplit_dotfile)
            create_symlink(*presplit_dotfile)
            assert os.path.islink(link_path)
            assert os.readlink(link_path) == link_dst
Ejemplo n.º 3
0
def test_symlink_already_exists_but_with_different_target(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.symlink('/bad/target', link_path)
            with pytest.raises(create_symlinks.InvalidLinkAlreadyExists):
                create_symlink(dirname, dotfile)
Ejemplo n.º 4
0
def test_directory_already_exists(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.mkdir(link_path)
            with pytest.raises(create_symlinks.DirectoryAlreadyExists):
                create_symlink(dirname, dotfile)
Ejemplo n.º 5
0
def test_symlink_already_exists_but_with_different_target(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.symlink('/bad/target', link_path)
            with pytest.raises(create_symlinks.InvalidLinkAlreadyExists):
                create_symlink(dirname, dotfile)
Ejemplo n.º 6
0
def test_directory_already_exists(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.mkdir(link_path)
            with pytest.raises(create_symlinks.DirectoryAlreadyExists):
                create_symlink(dirname, dotfile)
Ejemplo n.º 7
0
def test_symlink_already_exists(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.symlink(link_dst, link_path)
            create_symlink(dirname, dotfile)
            assert os.path.islink(link_path)
            assert os.readlink(link_path) == link_dst
Ejemplo n.º 8
0
def test_symlink_already_exists(tmpdir):
    dirname = '.dirname'
    dotfile = 'test_dotfile'
    test_home_dir = str(tmpdir.join('test_home_dir'))
    test_repo_dir = '/test/repo/path'
    with patch('create_symlinks.HOME_PATH', new=test_home_dir):
        create_directory(dirname)
        with patch('create_symlinks.REPO_PATH', new=test_repo_dir):
            link_path = os.path.join(test_home_dir, dirname, dotfile)
            link_dst = os.path.join(test_repo_dir, dirname, dotfile)
            os.symlink(link_dst, link_path)
            create_symlink(dirname, dotfile)
            assert os.path.islink(link_path)
            assert os.readlink(link_path) == link_dst