예제 #1
0
def test_stow_with_write_only_source(source_a, source_c, dest):
    utils.remove_read_permission(source_a)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a, source_c], dest)
    assert (error.InsufficientPermissionsToSubcmdFrom(subcmd=SUBCMD,
                                                      file=source_a).msg
            in str(e.value))
예제 #2
0
def test_unstow_with_read_only_dest(source_a, dest):
    dploy.stow([source_a], dest)
    utils.remove_write_permission(dest)
    message = str(
        error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD, file=dest))
    with pytest.raises(error.InsufficientPermissionsToSubcmdTo, match=message):
        dploy.unstow([source_a], dest)
예제 #3
0
def test_stow_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    with pytest.raises(NotADirectoryError) as e:
        dploy.stow([source_a], 'dest')
    assert (error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD,
                                              file=non_existant_dest).msg
            in str(e.value))
예제 #4
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_unfolding_with_write_only_source_file(source_a, source_b, dest):
    source_file = os.path.join(source_a, 'aaa')
    utils.remove_read_permission(source_file)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a, source_b], dest)
    assert (error.InsufficientPermissionsToSubcmdFrom(
        subcmd=SUBCMD, file=source_file).msg in str(e.value))
예제 #5
0
파일: test_unstow.py 프로젝트: sleach/dploy
def test_unstow_folding_with_existing_file_in_dest(source_a, source_b, dest):
    os.mkdir(os.path.join(dest, 'aaa'))
    a_file = os.path.join(dest, 'aaa', 'a_file')
    utils.create_file(a_file)
    dploy.stow([source_a, source_b], dest)
    dploy.unstow([source_a], dest)
    assert os.path.exists(a_file)
예제 #6
0
def test_ignore_file_by_ignoring_everthing__(source_a, source_c,
                                             file_dploystowignore, dest):
    ignore_patterns = ['*/aaa']
    with open(file_dploystowignore, 'w') as file:
        file.write("\n".join(ignore_patterns))
    dploy.stow([source_a, source_c], dest)
    assert not os.path.exists(os.path.join(dest, 'aaa'))
예제 #7
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_source_with_no_executue_permissions(source_a, source_c,
                                                       dest):
    utils.remove_execute_permission(source_a)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a, source_c], dest)
    assert (error.InsufficientPermissionsToSubcmdFrom(
        subcmd=SUBCMD, file=source_a).msg in str(e.value))
예제 #8
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_read_only_dest(source_a, dest):
    utils.remove_write_permission(dest)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a], dest)
    assert (error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD,
                                                    file=dest).msg in str(
                                                        e.value))
예제 #9
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_non_existant_source(dest):
    non_existant_source = 'source'
    with pytest.raises(NotADirectoryError) as e:
        dploy.stow([non_existant_source], dest)
    assert (error.NoSuchDirectory(subcmd=SUBCMD,
                                  file=non_existant_source).msg in str(
                                      e.value))
예제 #10
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    message = str(
        error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD,
                                          file=non_existant_dest))
    with pytest.raises(error.NoSuchDirectoryToSubcmdInto, match=message):
        dploy.stow([source_a], 'dest')
예제 #11
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_same_simple_directory_used_as_source_and_dest(
        source_only_files):
    with pytest.raises(ValueError) as e:
        dploy.stow([source_only_files], source_only_files)
    assert (error.SourceIsSameAsDest(subcmd=SUBCMD,
                                     file=source_only_files).msg in str(
                                         e.value))
예제 #12
0
파일: test_unstow.py 프로젝트: sleach/dploy
def test_unstow_with_read_only_dest(source_a, dest):
    dploy.stow([source_a], dest)
    utils.remove_write_permission(dest)
    with pytest.raises(PermissionError) as e:
        dploy.unstow([source_a], dest)
    assert error.InsufficientPermissionsToSubcmdTo(
        subcmd=SUBCMD, file=dest).msg in str(e.value)
예제 #13
0
파일: test_clean.py 프로젝트: arecarn/dploy
def test_clean_after_stow_not_removing_invalid_link_from_other_source(source_a, dest):
    dploy.stow([source_a], dest)
    broken = os.path.join('..', 'source_b', 'bbb')
    dest_path = os.path.join(dest, 'bbb')
    os.symlink(broken, dest_path)
    assert os.readlink(dest_path) == broken
    dploy.clean([source_a], dest)
    assert os.readlink(dest_path) == broken
예제 #14
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_write_only_source(source_a, source_c, dest):
    utils.remove_read_permission(source_a)
    message = str(
        error.InsufficientPermissionsToSubcmdFrom(subcmd=SUBCMD,
                                                  file=source_a))
    with pytest.raises(error.InsufficientPermissionsToSubcmdFrom,
                       match=message):
        dploy.stow([source_a, source_c], dest)
예제 #15
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_unfolding_with_first_sources_execute_permission_removed(
        source_a, source_b, dest):
    dploy.stow([source_a], dest)
    utils.remove_execute_permission(source_a)
    dest_dir = os.path.join(dest, 'aaa')
    message = str(error.PermissionDenied(subcmd=SUBCMD, file=dest_dir))
    with pytest.raises(error.PermissionDenied, match=message):
        dploy.stow([source_b], dest)
예제 #16
0
def test_stow_unfolding_with_write_only_source_file(source_a, source_b, dest):
    source_file = os.path.join(source_a, 'aaa')
    utils.remove_read_permission(source_file)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a, source_b], dest)
    assert (error.InsufficientPermissionsToSubcmdFrom(subcmd=SUBCMD,
                                                      file=source_file).msg
            in str(e.value))
예제 #17
0
def test_unstow_folding_with_multiple_sources_with_execute_permission_unset(
        source_a, source_b, dest):
    dploy.stow([source_a, source_b], dest)
    utils.remove_execute_permission(source_b)
    dest_dir = os.path.join(dest, 'aaa', 'ddd')
    message = str(error.PermissionDenied(subcmd=SUBCMD, file=dest_dir))
    with pytest.raises(error.PermissionDenied, match=message):
        dploy.unstow([source_a], dest)
예제 #18
0
def test_stow_with_source_dir_with_no_executue_permissions(
        source_a, source_c, dest):
    source_dir = os.path.join(source_a, 'aaa')
    utils.remove_execute_permission(source_dir)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_a, source_c], dest)
    assert (error.InsufficientPermissionsToSubcmdFrom(subcmd=SUBCMD,
                                                      file=source_dir).msg
            in str(e.value))
예제 #19
0
def test_clean_after_stow_not_removing_invalid_link_from_other_source(
        source_a, dest):
    dploy.stow([source_a], dest)
    broken = os.path.join('..', 'source_b', 'bbb')
    dest_path = os.path.join(dest, 'bbb')
    os.symlink(broken, dest_path)
    assert os.readlink(dest_path) == broken
    dploy.clean([source_a], dest)
    assert os.readlink(dest_path) == broken
예제 #20
0
def test_stow_with_source_conflicts(source_a, source_c, dest):
    with pytest.raises(ValueError) as e:
        dploy.stow([source_a, source_c], dest)
    conflicting_source_files = [
        os.path.join(source_a, 'aaa', 'aaa'),
        os.path.join(source_c, 'aaa', 'aaa'),
    ]
    assert (error.ConflictsWithAnotherSource(
        subcmd=SUBCMD, files=conflicting_source_files).msg in str(e.value))
예제 #21
0
def test_stow_unfolding_with_first_sources_execute_permission_removed(
        source_a, source_b, dest):
    dploy.stow([source_a], dest)
    utils.remove_execute_permission(source_a)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_b], dest)
    dest_dir = os.path.join(dest, 'aaa')
    assert (error.PermissionDenied(subcmd=SUBCMD, file=dest_dir).msg
            in str(e.value))
예제 #22
0
def test_unstow_with_dest_dir_with_no_executue_permissions(
        source_a, source_b, dest):
    dest_dir = os.path.join(dest, 'aaa')
    dploy.stow([source_a, source_b], dest)
    utils.remove_execute_permission(os.path.join(dest, 'aaa'))
    message = str(
        error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD, file=dest_dir))
    with pytest.raises(error.InsufficientPermissionsToSubcmdTo, match=message):
        dploy.unstow([source_a, source_b], dest)
예제 #23
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_existing_file_conflicts(source_a, source_c, dest):
    dploy.stow([source_a], dest)
    with pytest.raises(ValueError) as e:
        dploy.stow([source_c], dest)
    source_file = os.path.join(source_c, 'aaa', 'aaa')
    conflicting_file = os.path.join(dest, 'aaa', 'aaa')
    assert (error.ConflictsWithExistingFile(
        subcmd=SUBCMD, source=source_file, dest=conflicting_file).msg in str(
            e.value))
예제 #24
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_source_conflicts(source_a, source_c, dest):
    with pytest.raises(ValueError) as e:
        dploy.stow([source_a, source_c], dest)
    conflicting_source_files = [
        os.path.join(source_a, 'aaa', 'aaa'),
        os.path.join(source_c, 'aaa', 'aaa'),
    ]
    assert (error.ConflictsWithAnotherSource(
        subcmd=SUBCMD, files=conflicting_source_files).msg in str(e.value))
예제 #25
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_unfolding_with_first_sources_execute_permission_removed(
        source_a, source_b, dest):
    dploy.stow([source_a], dest)
    utils.remove_execute_permission(source_a)
    with pytest.raises(PermissionError) as e:
        dploy.stow([source_b], dest)
    dest_dir = os.path.join(dest, 'aaa')
    assert (error.PermissionDenied(subcmd=SUBCMD, file=dest_dir).msg in str(
        e.value))
예제 #26
0
파일: test_unstow.py 프로젝트: sleach/dploy
def test_unstow_folding_with_multiple_sources_with_execute_permission_unset(
        source_a, source_b, dest):
    dploy.stow([source_a, source_b], dest)
    utils.remove_execute_permission(source_b)
    with pytest.raises(PermissionError) as e:
        dploy.unstow([source_a], dest)
    dest_dir = os.path.join(dest, 'aaa', 'ddd')
    assert error.PermissionDenied(subcmd=SUBCMD,
                                  file=dest_dir).msg in str(e.value)
예제 #27
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_existing_broken_link(source_a, dest):
    conflicting_link = os.path.join(dest, 'aaa')
    os.symlink('non_existant_source', conflicting_link)
    with pytest.raises(ValueError) as e:
        dploy.stow([source_a], dest)
    source_file = os.path.join(source_a, 'aaa')
    assert (error.ConflictsWithExistingLink(
        subcmd=SUBCMD, source=source_file, dest=conflicting_link).msg in str(
            e.value))
예제 #28
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_source_conflicts(source_a, source_c, dest):
    conflicting_source_files = [
        os.path.join(source_a, 'aaa', 'aaa'),
        os.path.join(source_c, 'aaa', 'aaa'),
    ]
    message = str(
        error.ConflictsWithAnotherSource(subcmd=SUBCMD,
                                         files=conflicting_source_files))
    with pytest.raises(error.ConflictsWithAnotherSource, match=message):
        dploy.stow([source_a, source_c], dest)
예제 #29
0
파일: test_unstow.py 프로젝트: sleach/dploy
def test_unstow_with_dest_dir_with_no_executue_permissions(
        source_a, source_b, dest):
    dest_dir = os.path.join(dest, 'aaa')
    dploy.stow([source_a, source_b], dest)
    utils.remove_execute_permission(os.path.join(dest, 'aaa'))
    with pytest.raises(PermissionError) as e:
        dploy.unstow([source_a, source_b], dest)
    assert error.InsufficientPermissionsToSubcmdTo(subcmd=SUBCMD,
                                                   file=dest_dir).msg in str(
                                                       e.value)
예제 #30
0
def test_stow_with_existing_broken_link(source_a, dest):
    conflicting_link = os.path.join(dest, 'aaa')
    os.symlink('non_existant_source', conflicting_link)
    with pytest.raises(ValueError) as e:
        dploy.stow([source_a], dest)
    source_file = os.path.join(source_a, 'aaa')
    assert (error.ConflictsWithExistingLink(subcmd=SUBCMD,
                                            source=source_file,
                                            dest=conflicting_link).msg
            in str(e.value))
예제 #31
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_source_dir_with_no_executue_permissions(
        source_a, source_c, dest):
    source_dir = os.path.join(source_a, 'aaa')
    utils.remove_execute_permission(source_dir)
    message = str(
        error.InsufficientPermissionsToSubcmdFrom(subcmd=SUBCMD,
                                                  file=source_dir))
    with pytest.raises(error.InsufficientPermissionsToSubcmdFrom,
                       match=message):
        dploy.stow([source_a, source_c], dest)
예제 #32
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_existing_broken_link(source_a, dest):
    conflicting_link = os.path.join(dest, 'aaa')
    os.symlink('non_existant_source', conflicting_link)
    source_file = os.path.join(source_a, 'aaa')
    message = str(
        error.ConflictsWithExistingLink(subcmd=SUBCMD,
                                        source=source_file,
                                        dest=conflicting_link))
    with pytest.raises(error.ConflictsWithExistingLink):
        dploy.stow([source_a], dest)
예제 #33
0
def test_stow_with_existing_file_conflicts(source_a, source_c, dest):
    dploy.stow([source_a], dest)
    with pytest.raises(ValueError) as e:
        dploy.stow([source_c], dest)
    source_file = os.path.join(source_c, 'aaa', 'aaa')
    conflicting_file = os.path.join(dest, 'aaa', 'aaa')
    assert (error.ConflictsWithExistingFile(subcmd=SUBCMD,
                                            source=source_file,
                                            dest=conflicting_file).msg
            in str(e.value))
예제 #34
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_existing_file_conflicts(source_a, source_c, dest):
    dploy.stow([source_a], dest)
    source_file = os.path.join(source_c, 'aaa', 'aaa')
    conflicting_file = os.path.join(dest, 'aaa', 'aaa')
    message = str(
        error.ConflictsWithExistingFile(subcmd=SUBCMD,
                                        source=source_file,
                                        dest=conflicting_file))
    with pytest.raises(error.ConflictsWithExistingFile, match=message):
        dploy.stow([source_c], dest)
예제 #35
0
파일: test_unstow.py 프로젝트: sleach/dploy
def test_unstow_folding_with_stray_symlink_in_unfolded_dest_dir(
        source_a, source_b, source_d, dest):
    """
    Given a dest directory with stowed packages that share a unfolded directory,
    that also contains a stray link along with the links created by stowing.

    When the stowed packages are unstowed

    Then the folded directory remains with the single stray symlink
    """
    stray_path = os.path.join(dest, 'aaa', 'ggg')
    dploy.stow([source_a, source_b], dest)
    dploy.link(os.path.join(source_d, 'aaa', 'ggg'), stray_path)
    dploy.unstow([source_a, source_b], dest)
    assert os.path.islink(stray_path)
예제 #36
0
 def use(self, package=None, **_kwargs):
     self.check_if_r2env_initialized()
     if not package:
         self.list_installed_packages()
         raise R2EnvException("Package not defined.")
     if package not in self._package_manager.list_installed_packages():
         raise R2EnvException(f"Package {package} not installed.")
     cur_ver = self._get_current_version()
     new_dst_dir = self._package_manager.get_package_path(package)
     if cur_ver:
         unstow([self._package_manager.get_package_path(cur_ver)],
                self._r2env_path)
     stow([new_dst_dir], self._r2env_path)
     self._set_current_version(package)
     print_console(f"[*] Using {package} package")
예제 #37
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_the_same_tree_twice(source_a, dest):
    dploy.stow([source_a], dest)
    dploy.stow([source_a], dest)
    assert os.readlink(os.path.join(dest, 'aaa')) == os.path.join(
        '..', 'source_a', 'aaa')
예제 #38
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_non_existant_dest(source_a):
    non_existant_dest = 'dest'
    with pytest.raises(NotADirectoryError) as e:
        dploy.stow([source_a], 'dest')
    assert (error.NoSuchDirectoryToSubcmdInto(
        subcmd=SUBCMD, file=non_existant_dest).msg in str(e.value))
예제 #39
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_duplicate_source(source_a, dest):
    with pytest.raises(ValueError) as e:
        dploy.stow([source_a, source_a], dest)
    assert error.DuplicateSource(
        subcmd=SUBCMD, file=source_a).msg in str(e.value)
예제 #40
0
def test_ignore_by_ignoring_only_subdirectory(source_a, source_c, dest):
    dploy.stow([source_a, source_c], dest, ignore_patterns=['aaa'])
    assert not os.path.exists(os.path.join(dest, 'aaa'))
예제 #41
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_file_as_source(file_a, dest):
    with pytest.raises(NotADirectoryError) as e:
        dploy.stow([file_a], dest)
    assert (error.NoSuchDirectory(subcmd=SUBCMD, file=file_a).msg in str(
        e.value))
예제 #42
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_basic_senario(source_a, dest):
    dploy.stow([source_a], dest)
    assert os.readlink(os.path.join(dest, 'aaa')) == os.path.join(
        '..', 'source_a', 'aaa')
예제 #43
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_simple_senario(source_only_files, dest):
    dploy.stow([source_only_files], dest)
    assert os.readlink(os.path.join(dest, 'aaa')) == os.path.join(
        '..', 'source_only_files', 'aaa')
예제 #44
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_file_as_dest(source_a, file_a):
    with pytest.raises(NotADirectoryError) as e:
        dploy.stow([source_a], file_a)
    assert (error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD,
                                              file=file_a).msg in str(e.value))
예제 #45
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_unfolding_with_two_invocations(source_a, source_b, dest):
    dploy.stow([source_a], dest)
    assert os.readlink(os.path.join(dest, 'aaa')) == os.path.join(
        '..', 'source_a', 'aaa')
    dploy.stow([source_b], dest)
    verify_unfolded_source_a_and_source_b(dest)
예제 #46
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_non_existant_source(dest):
    non_existant_source = 'source'
    message = str(
        error.NoSuchDirectory(subcmd=SUBCMD, file=non_existant_source))
    with pytest.raises(error.NoSuchDirectory, match=message):
        dploy.stow([non_existant_source], dest)
예제 #47
0
def test_ignore_by_ignoring_everthing__(source_a, source_c, dest):
    dploy.stow([source_a, source_c], dest, ignore_patterns=['*/aaa'])
    assert not os.path.exists(os.path.join(dest, 'aaa'))
예제 #48
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_write_only_source_file(source_a, dest):
    source_file = os.path.join(source_a, 'aaa')
    utils.remove_read_permission(source_file)
    dploy.stow([source_a], dest)
예제 #49
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_duplicate_source(source_a, dest):
    message = str(error.DuplicateSource(subcmd=SUBCMD, file=source_a))
    with pytest.raises(error.DuplicateSource, match=message):
        dploy.stow([source_a, source_a], dest)
예제 #50
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_unfolding_with_mutliple_sources(source_a, source_b, dest):
    dploy.stow([source_a, source_b], dest)
    verify_unfolded_source_a_and_source_b(dest)
예제 #51
0
파일: test_stow.py 프로젝트: thieryl/dploy
def test_stow_with_file_as_source(file_a, dest):
    message = str(error.NoSuchDirectory(subcmd=SUBCMD, file=file_a))
    with pytest.raises(error.NoSuchDirectory, match=message):
        dploy.stow([file_a], dest)
예제 #52
0
파일: test_stow.py 프로젝트: arecarn/dploy
def test_stow_with_the_same_tree_twice(source_a, dest):
    dploy.stow([source_a], dest)
    dploy.stow([source_a], dest)
    assert os.readlink(os.path.join(dest, 'aaa')) == os.path.join(
        '..', 'source_a', 'aaa')