Unit test added.

This commit is contained in:
Aaron Tan 2017-03-16 11:08:19 -04:00
parent 95e41e078c
commit 90bcc3d6ab
2 changed files with 15 additions and 3 deletions

View File

@ -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

View File

@ -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