Пример #1
0
    def _is_valid_dest(self, dest):
        """
        Check if the test argument is valid
        """
        result = True

        if not dest.is_dir():
            self.errors.add(
                error.NoSuchDirectoryToSubcmdInto(self.subcmd, dest))
            result = False
        else:
            if not utils.is_directory_writable(dest):
                self.errors.add(
                    error.InsufficientPermissionsToSubcmdTo(self.subcmd, dest))
                result = False

            if not utils.is_directory_readable(dest):
                self.errors.add(
                    error.InsufficientPermissionsToSubcmdTo(self.subcmd, dest))
                result = False

            if not utils.is_directory_executable(dest):
                self.errors.add(
                    error.InsufficientPermissionsToSubcmdTo(self.subcmd, dest))
                result = False

        return result
Пример #2
0
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')
Пример #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
    def _collect_actions(self, source, dest):
        """
        Concrete method to collect required actions to perform a link
        sub-command
        """

        if dest.exists():
            if utils.is_same_file(dest, source):
                self.actions.add(
                    actions.AlreadyLinked(self.subcmd, source, dest))
            else:
                self.errors.add(
                    error.ConflictsWithExistingFile(self.subcmd, source, dest))
        elif dest.is_symlink():
            self.errors.add(
                error.ConflictsWithExistingLink(self.subcmd, source, dest))

        elif not dest.parent.exists():
            self.errors.add(
                error.NoSuchDirectoryToSubcmdInto(self.subcmd, dest.parent))

        else:
            self.actions.add(actions.SymbolicLink(self.subcmd, source, dest))
Пример #5
0
def test_stow_with_file_as_dest_and_source(file_a, file_b):
    message = str(error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD,
                                                    file=file_b))
    with pytest.raises(error.NoSuchDirectoryToSubcmdInto, match=message):
        dploy.stow([file_a], file_b)
Пример #6
0
def test_unstow_with_file_as_source_and_dest(file_a, file_b):
    with pytest.raises(NotADirectoryError) as e:
        dploy.unstow([file_a], file_b)
    assert (error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD, file=file_b).msg
            in str(e.value))
Пример #7
0
def test_unstow_with_file_as_dest(source_a, file_a):
    message = str(error.NoSuchDirectoryToSubcmdInto(subcmd=SUBCMD,
                                                    file=file_a))
    with pytest.raises(error.NoSuchDirectoryToSubcmdInto, match=message):
        dploy.unstow([source_a], file_a)