fix KeyError for default, added tests

This commit is contained in:
Wayne Witzel III
2017-01-30 12:15:43 -05:00
parent ba2ff026b3
commit 5ace8dad4e
3 changed files with 33 additions and 2 deletions

View File

@@ -127,8 +127,8 @@ class SurveyJobTemplateMixin(models.Model):
# Overwrite with job template extra vars with survey default vars
if self.survey_enabled and 'spec' in self.survey_spec:
for survey_element in self.survey_spec.get("spec", []):
default = survey_element['default']
variable_key = survey_element['variable']
default = survey_element.get('default')
variable_key = survey_element.get('variable')
if survey_element.get('type') == 'password':
if variable_key in kwargs_extra_vars:
kw_value = kwargs_extra_vars[variable_key]