From 90bcc3d6ab1405f2ba4a691bb4667bbacba76ee3 Mon Sep 17 00:00:00 2001 From: Aaron Tan Date: Thu, 16 Mar 2017 11:08:19 -0400 Subject: [PATCH] Unit test added. --- awx/main/models/jobs.py | 5 ++--- .../tests/unit/models/test_job_template_unit.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/awx/main/models/jobs.py b/awx/main/models/jobs.py index b960b0fbd4..992217ec33 100644 --- a/awx/main/models/jobs.py +++ b/awx/main/models/jobs.py @@ -311,9 +311,8 @@ class JobTemplate(UnifiedJobTemplate, JobOptions, SurveyJobTemplateMixin, Resour variables_needed = True prompting_needed = False for key, value in self._ask_for_vars_dict().iteritems(): - if value and not (key == 'extra_vars' - and callback_extra_vars is not None - and not variables_needed): + if value and not (key == 'extra_vars' and + callback_extra_vars is not None): prompting_needed = True return (not prompting_needed and not self.passwords_needed_to_start and diff --git a/awx/main/tests/unit/models/test_job_template_unit.py b/awx/main/tests/unit/models/test_job_template_unit.py index 194ce68cef..a6086b7b9d 100644 --- a/awx/main/tests/unit/models/test_job_template_unit.py +++ b/awx/main/tests/unit/models/test_job_template_unit.py @@ -115,3 +115,16 @@ def test_job_template_survey_mixin_length(job_template_factory): {'type':'password', 'variable':'my_other_variable'}]} kwargs = obj._update_unified_job_kwargs(extra_vars={'my_variable':'$encrypted$'}) assert kwargs['extra_vars'] == '{"my_variable": "my_default"}' + + +def test_job_template_can_start_with_callback_extra_vars_provided(job_template_factory): + objects = job_template_factory( + 'callback_extra_vars_test', + organization='org1', + inventory='inventory1', + credential='cred1', + persisted=False, + ) + obj = objects.job_template + obj.ask_variables_on_launch = True + assert obj.can_start_without_user_input(callback_extra_vars='{"foo": "bar"}') is True