def apply_partitioning(self, module): """Apply a partitioning. :param module: a partitioning module :raise: InvalidStorageError of the partitioning is not valid """ # Validate the partitioning. storage = module.storage task = StorageValidateTask(storage) task.run() # Apply the partitioning. self.set_storage(storage.copy()) log.debug("Applied the partitioning %s.", module)
def validation_test(self, storage_checker): """Test the validation task.""" storage = Mock() report = StorageCheckerReport() storage_checker.check.return_value = report StorageValidateTask(storage).run()
def apply_partitioning(self, module): """Apply a partitioning. :param module: a partitioning module :raise: InvalidStorageError of the partitioning is not valid """ # Validate the partitioning. storage = module.storage.copy() task = StorageValidateTask(storage) report = task.run() if not report.is_valid(): raise InvalidStorageError(" ".join(report.error_messages)) # Apply the partitioning. self._set_storage_playground(storage) self._set_applied_partitioning(module)
def apply_partitioning(self, object_path): """Apply a partitioning. :param object_path: an object path of a partitioning module :raise: InvalidStorageError of the partitioning is not valid """ # Get the partitioning module. module = self._partitioning_modules.get(object_path) if not module: raise ValueError("Unknown partitioning {}.".format(object_path)) # Validate the partitioning. storage = module.storage task = StorageValidateTask(storage) task.run() # Apply the partitioning. self.set_storage(storage.copy()) log.debug("Applied the partitioning from %s.", object_path)
def validate_with_task(self): """Validate the scheduled partitioning. Run sanity checks on the current storage model to verify if the partitioning is valid. The result of the task is a validation report. :return: a task """ return StorageValidateTask(self.storage)
def validation_failed_test(self, storage_checker): """Test the validation task.""" storage = Mock() report = StorageCheckerReport() report.add_error("Fake error.") storage_checker.check.return_value = report with self.assertRaises(InvalidStorageError) as cm: StorageValidateTask(storage).run() self.assertEqual(str(cm.exception), "Fake error.")
def validate_with_task(self): """Validate the scheduled partitions.""" task = StorageValidateTask(self.storage) path = self.publish_task(MANUAL_PARTITIONING.namespace, task) return path
def validate_with_task(self): """Validate the scheduled partitions.""" return StorageValidateTask(self.storage)