def test_postprocess_build(self): """ postprocess_build should trigger the importing of the build's artifacts, and then schedule any other post-build tasks. """ job = JobFactory.create() build = BuildFactory.create(job=job) with mock.patch("jenkins.helpers.chain") as chain_mock: postprocess_build(build) chain_mock.assert_called_once_with(import_build_for_job.s(build.pk)) chain_mock.return_value.apply_async.assert_called_once()
def postprocess_build(build): """ Queues importing the specified build from Jenkins including details of the artifacts etc. When a build completes, execute any tasks that should be executed post build. """ post_build_tasks = getattr(settings, "POST_BUILD_TASKS", []) additional_tasks = [x.s() for x in post_build_tasks] return chain( import_build_for_job.s(build.pk), *additional_tasks).apply_async()
def postprocess_build(build): """ Queues importing the specified build from Jenkins including details of the artifacts etc. When a build completes, execute any tasks that should be executed post build. """ post_build_tasks = getattr(settings, "POST_BUILD_TASKS", []) additional_tasks = [x.s() for x in post_build_tasks] return chain(import_build_for_job.s(build.pk), *additional_tasks).apply_async()
def test_postprocess_build(self): """ postprocess_build should trigger the importing of the build's artifacts, and then schedule any other post-build tasks. """ job = JobFactory.create() build = BuildFactory.create(job=job) with mock.patch("jenkins.helpers.chain") as chain_mock: postprocess_build(build) chain_mock.assert_called_once_with( import_build_for_job.s(build.pk)) chain_mock.return_value.apply_async.assert_called_once()
def test_postprocess_build_with_additional_postprocess_tasks(self): """ If settings.POST_BUILD_TASKS has a list of additional tasks to be executed after a build completes, then we should chain them after we've imported the artifacts for the build. """ job = JobFactory.create() build = BuildFactory.create(job=job) with mock.patch("jenkins.helpers.chain") as chain_mock: postprocess_build(build) chain_mock.assert_called_once_with(import_build_for_job.s(build.pk), postbuild_testing_hook.s()) chain_mock.return_value.apply_async.assert_called_once()
def test_postprocess_build_with_additional_postprocess_tasks(self): """ If settings.POST_BUILD_TASKS has a list of additional tasks to be executed after a build completes, then we should chain them after we've imported the artifacts for the build. """ job = JobFactory.create() build = BuildFactory.create(job=job) with mock.patch("jenkins.helpers.chain") as chain_mock: postprocess_build(build) chain_mock.assert_called_once_with( import_build_for_job.s(build.pk), postbuild_testing_hook.s()) chain_mock.return_value.apply_async.assert_called_once()