Ejemplo n.º 1
0
    def test_validate_with_task(self, publisher):
        """Test ValidateWithTask."""
        self.module.on_storage_changed(Mock())
        task_path = self.interface.ValidateWithTask()

        obj = check_task_creation(task_path, publisher, StorageValidateTask)
        assert obj.implementation._storage == self.module.storage

        report = ValidationReport()
        report.error_messages = [
            "Something is wrong.", "Something is very wrong."
        ]
        report.warning_messages = ["Something might be wrong."]
        obj.implementation._set_result(report)

        result = obj.GetResult()
        expected_result = get_variant(
            Structure, {
                "error-messages":
                get_variant(
                    List[Str],
                    ["Something is wrong.", "Something is very wrong."]),
                "warning-messages":
                get_variant(List[Str], ["Something might be wrong."])
            })

        assert isinstance(result, Variant)
        assert get_native(result) == get_native(expected_result)
        assert result.equal(expected_result)
Ejemplo n.º 2
0
    def validate_selected_disks(self, drives):
        """Validate the list of selected disks.

        :param drives: a list of drives names
        :return: a validation report
        """
        report = ValidationReport()
        report.error_messages = check_disk_selection(self.storage, drives)
        return report
Ejemplo n.º 3
0
    def _validate_storage(self, storage):
        """Validate the storage model.

        :param storage: an instance of Blivet
        :return: a validation report
        """
        result = storage_checker.check(storage)

        for message in result.info:
            log.debug(message)

        validation_report = ValidationReport()
        validation_report.error_messages = result.errors
        validation_report.warning_messages = result.warnings

        return validation_report