mirror of
https://github.com/ansible/awx.git
synced 2026-08-02 02:49:58 -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):
|
def variables_needed_to_start(self):
|
||||||
vars = []
|
vars = []
|
||||||
if self.survey_enabled:
|
if self.survey_enabled:
|
||||||
for survey_element in self.survey_spec:
|
for survey_element in self.survey_spec["spec"]:
|
||||||
if survey_element['required']:
|
if survey_element['required']:
|
||||||
vars.append(survey_element['variable'])
|
vars.append(survey_element['variable'])
|
||||||
return vars
|
return vars
|
||||||
@@ -224,7 +224,11 @@ class JobTemplate(UnifiedJobTemplate, JobOptions):
|
|||||||
errors = []
|
errors = []
|
||||||
if not self.survey_enabled:
|
if not self.survey_enabled:
|
||||||
return errors
|
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 \
|
if survey_element['variable'] not in data and \
|
||||||
survey_element['required']:
|
survey_element['required']:
|
||||||
errors.append("'%s' value missing" % survey_element['variable'])
|
errors.append("'%s' value missing" % survey_element['variable'])
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ TEST_ASYNC_PLAYBOOK = '''
|
|||||||
'''
|
'''
|
||||||
|
|
||||||
TEST_SIMPLE_REQUIRED_SURVEY = '''
|
TEST_SIMPLE_REQUIRED_SURVEY = '''
|
||||||
[
|
{
|
||||||
|
"title": "Simple",
|
||||||
|
"description": "Description",
|
||||||
|
"spec": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"question_name": "favorite color",
|
"question_name": "favorite color",
|
||||||
@@ -62,10 +65,14 @@ TEST_SIMPLE_REQUIRED_SURVEY = '''
|
|||||||
"default": "blue"
|
"default": "blue"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
TEST_SIMPLE_NONREQUIRED_SURVEY = '''
|
TEST_SIMPLE_NONREQUIRED_SURVEY = '''
|
||||||
[
|
{
|
||||||
|
"title": "Simple",
|
||||||
|
"description": "Description",
|
||||||
|
"spec": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"question_name": "unladen swallow",
|
"question_name": "unladen swallow",
|
||||||
@@ -78,10 +85,14 @@ TEST_SIMPLE_NONREQUIRED_SURVEY = '''
|
|||||||
"default": "european"
|
"default": "european"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
TEST_SURVEY_REQUIREMENTS = '''
|
TEST_SURVEY_REQUIREMENTS = '''
|
||||||
[
|
{
|
||||||
|
"title": "Simple",
|
||||||
|
"description": "Description",
|
||||||
|
"spec": [
|
||||||
{
|
{
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"question_name": "cantbeshort",
|
"question_name": "cantbeshort",
|
||||||
@@ -171,6 +182,7 @@ TEST_SURVEY_REQUIREMENTS = '''
|
|||||||
"default": ""
|
"default": ""
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
class BaseJobTestMixin(BaseTestMixin):
|
class BaseJobTestMixin(BaseTestMixin):
|
||||||
|
|||||||
Reference in New Issue
Block a user