Fixes delete-all command when no option is provided

Change-Id: Ibc06209c2ec19045e12a145083a64a179d57d731
Implements: fix for delete-all command without option
Closes-Bug: #2001207
This commit is contained in:
Truc Nguyen 2017-09-20 15:46:19 +02:00 committed by Sorin Sbarnea
parent 307c09cff3
commit c051dd8502
No known key found for this signature in database
GPG Key ID: B85725D917D27B8A
2 changed files with 6 additions and 4 deletions

View File

@ -69,10 +69,10 @@ class DeleteAllSubCommand(base.BaseSubCommand):
'Job Builder)'.format(" AND ".join(reach))):
sys.exit('Aborted')
if options.del_jobs:
if 'jobs' in reach:
logger.info("Deleting all jobs")
builder.delete_all_jobs()
if options.del_views:
if 'views' in reach:
logger.info("Deleting all views")
builder.delete_all_views()

View File

@ -33,8 +33,10 @@ class DeleteAllTests(CmdTestsBase):
"""
args = ['--conf', self.default_config_file, 'delete-all']
with mock.patch('jenkins_jobs.utils.input', return_value="y"):
self.execute_jenkins_jobs_with_args(args)
with mock.patch('jenkins_jobs.builder.JenkinsManager.get_views',
return_value=[None]):
with mock.patch('jenkins_jobs.utils.input', return_value="y"):
self.execute_jenkins_jobs_with_args(args)
@mock.patch('jenkins_jobs.cli.subcommand.update.'
'JenkinsManager.delete_all_jobs')