Merge "Regression test for update command with --delete-old"
This commit is contained in:
commit
771a94227c
|
@ -92,26 +92,29 @@ class UpdateTests(CmdTestsBase):
|
||||||
* mock out a call to jenkins.Jenkins.job_exists() to always return
|
* mock out a call to jenkins.Jenkins.job_exists() to always return
|
||||||
True.
|
True.
|
||||||
"""
|
"""
|
||||||
jobs = ['old_job001', 'old_job002', 'unmanaged']
|
yaml_jobs = ['bar001', 'bar002', 'baz001', 'bam001']
|
||||||
extra_jobs = [{'name': name} for name in jobs]
|
extra_jobs = ['old_job001', 'old_job002', 'unmanaged']
|
||||||
|
|
||||||
path = os.path.join(self.fixtures_path, 'cmd-002.yaml')
|
path = os.path.join(self.fixtures_path, 'cmd-002.yaml')
|
||||||
args = ['--conf', self.default_config_file, 'update', '--delete-old',
|
args = ['--conf', self.default_config_file, 'update', '--delete-old',
|
||||||
path]
|
path]
|
||||||
|
|
||||||
jenkins_get_jobs.return_value = extra_jobs
|
jenkins_get_jobs.return_value = [{'name': name}
|
||||||
|
for name in yaml_jobs + extra_jobs]
|
||||||
|
|
||||||
with mock.patch('jenkins_jobs.builder.JenkinsManager.is_managed',
|
with mock.patch('jenkins_jobs.builder.JenkinsManager.is_managed',
|
||||||
side_effect=(lambda name: name != 'unmanaged')):
|
side_effect=(lambda name: name != 'unmanaged')):
|
||||||
self.execute_jenkins_jobs_with_args(args)
|
self.execute_jenkins_jobs_with_args(args)
|
||||||
|
|
||||||
jenkins_reconfig_job.assert_has_calls(
|
jenkins_reconfig_job.assert_has_calls(
|
||||||
[mock.call(job_name, mock.ANY)
|
[mock.call(job_name, mock.ANY) for job_name in yaml_jobs],
|
||||||
for job_name in ['bar001', 'bar002', 'baz001', 'bam001']],
|
|
||||||
any_order=True
|
any_order=True
|
||||||
)
|
)
|
||||||
jenkins_delete_job.assert_has_calls(
|
calls = [mock.call(name) for name in extra_jobs if name != 'unmanaged']
|
||||||
[mock.call(name) for name in jobs if name != 'unmanaged'])
|
jenkins_delete_job.assert_has_calls(calls)
|
||||||
|
# to ensure only the calls we expected were made, have to check
|
||||||
|
# there were no others, as no API call for assert_has_only_calls
|
||||||
|
self.assertEquals(jenkins_delete_job.call_count, len(calls))
|
||||||
|
|
||||||
def test_update_timeout_not_set(self):
|
def test_update_timeout_not_set(self):
|
||||||
"""Validate update timeout behavior when timeout not explicitly configured.
|
"""Validate update timeout behavior when timeout not explicitly configured.
|
||||||
|
|
Loading…
Reference in New Issue