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)
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