def test_remove_error(popen, stack_id, dry_run, force): senza = Senza('region') senza.logger = MagicMock() popen.returncode = 1 with pytest.raises(ExecutionError): senza.remove(stack_id, dry_run=dry_run, force=force)
def delete_stack(stack_id: str, delete_options: dict) -> dict: """ DELETE /stacks/{id} Delete a stack """ sentry_client.capture_breadcrumb(data={ 'stack_id': stack_id, 'delete_options': delete_options, }) dry_run = delete_options.get('dry_run', False) force = delete_options.get('force', False) region = delete_options.get('region', config.region) # type: Optional[str] senza = Senza(region) logger.info("Removing stack %s...", stack_id) running_time = MeasureRunningTime('delete_stack.success') output = senza.remove(stack_id, dry_run=dry_run, force=force) running_time.finish() logger.info("Stack %s removed.", stack_id) return '', 204, _make_headers(output=output)
def test_remove(popen, stack_id, region, dry_run, force): senza = Senza(region) senza.logger = MagicMock() senza.remove(stack_id, dry_run=dry_run, force=force) dry_run_flag = ['--dry-run'] if dry_run else [] force_flag = ['--force'] if force else [] stack_name, stack_ver = stack_id.rsplit("-", 1) popen.assert_called_with(['senza', 'delete'] + ['--region', region] + dry_run_flag + force_flag + [stack_name, stack_ver], stdout=-1, stderr=-2) assert not senza.logger.error.called assert not senza.logger.exception.called