mirror of
https://github.com/ansible/awx.git
synced 2026-05-24 09:07:45 -02:30
Take survey title and description into account
This commit is contained in:
@@ -215,7 +215,7 @@ class JobTemplate(UnifiedJobTemplate, JobOptions):
|
||||
def variables_needed_to_start(self):
|
||||
vars = []
|
||||
if self.survey_enabled:
|
||||
for survey_element in self.survey_spec:
|
||||
for survey_element in self.survey_spec["spec"]:
|
||||
if survey_element['required']:
|
||||
vars.append(survey_element['variable'])
|
||||
return vars
|
||||
@@ -224,7 +224,11 @@ class JobTemplate(UnifiedJobTemplate, JobOptions):
|
||||
errors = []
|
||||
if not self.survey_enabled:
|
||||
return errors
|
||||
for survey_element in self.survey_spec:
|
||||
if 'title' not in self.survey_spec:
|
||||
errors.append("'title' missing from survey spec")
|
||||
if 'description' not in self.survey_spec:
|
||||
errors.append("'description' missing from survey spec")
|
||||
for survey_element in self.survey_spec["spec"]:
|
||||
if survey_element['variable'] not in data and \
|
||||
survey_element['required']:
|
||||
errors.append("'%s' value missing" % survey_element['variable'])
|
||||
|
||||
@@ -49,7 +49,10 @@ TEST_ASYNC_PLAYBOOK = '''
|
||||
'''
|
||||
|
||||
TEST_SIMPLE_REQUIRED_SURVEY = '''
|
||||
[
|
||||
{
|
||||
"title": "Simple",
|
||||
"description": "Description",
|
||||
"spec": [
|
||||
{
|
||||
"type": "text",
|
||||
"question_name": "favorite color",
|
||||
@@ -61,11 +64,15 @@ TEST_SIMPLE_REQUIRED_SURVEY = '''
|
||||
"required": true,
|
||||
"default": "blue"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
'''
|
||||
|
||||
TEST_SIMPLE_NONREQUIRED_SURVEY = '''
|
||||
[
|
||||
{
|
||||
"title": "Simple",
|
||||
"description": "Description",
|
||||
"spec": [
|
||||
{
|
||||
"type": "text",
|
||||
"question_name": "unladen swallow",
|
||||
@@ -77,11 +84,15 @@ TEST_SIMPLE_NONREQUIRED_SURVEY = '''
|
||||
"required": false,
|
||||
"default": "european"
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
'''
|
||||
|
||||
TEST_SURVEY_REQUIREMENTS = '''
|
||||
[
|
||||
{
|
||||
"title": "Simple",
|
||||
"description": "Description",
|
||||
"spec": [
|
||||
{
|
||||
"type": "text",
|
||||
"question_name": "cantbeshort",
|
||||
@@ -170,7 +181,8 @@ TEST_SURVEY_REQUIREMENTS = '''
|
||||
"required": false,
|
||||
"default": ""
|
||||
}
|
||||
]
|
||||
]
|
||||
}
|
||||
'''
|
||||
|
||||
class BaseJobTestMixin(BaseTestMixin):
|
||||
|
||||
Reference in New Issue
Block a user