def save_data_storage(cls, name, description, sts_duration, lts_duration, versioning, backup_duration, type, parent_folder, on_cloud, path): directory = None if parent_folder: directory = Folder.load(parent_folder) if directory is None: click.echo("Error: Directory with name '{}' not found! " "Check if it exists and you have permission to read it".format(parent_folder), err=True) sys.exit(1) try: DataStorage.save(name, path, description, sts_duration, lts_duration, versioning, backup_duration, type, directory.id if directory else None, on_cloud) except (ConfigNotFoundError, requests.exceptions.RequestException, RuntimeError, ValueError) as error: click.echo('Error: %s' % str(error), err=True) sys.exit(1)
def test_save_storage(self, mock): mock.post(mocked_url("datastorage/save"), text=mock_datastorage(self.storage_id, self.name, self.path, self.type, mock_storage_policy(self.backup_duration, self.lts_duration, self.sts_duration, self.versioning))) actual = DataStorage.save(self.name, self.path, self.description, self.sts_duration, self.lts_duration, self.versioning, self.backup_duration, self.type, self.parent_folder_id, self.on_cloud) expected = build_storage_model(identifier=self.storage_id, name=self.name, path=self.path, storage_type=self.type, policy=build_storage_policy(self.backup_duration, self.lts_duration, self.sts_duration, self.versioning)) assert_storages(actual, expected)