add tests that trigger error without fix provided

This commit is contained in:
Chris Meyers 2015-04-28 08:28:36 -04:00
parent cea9dbdb4f
commit df6b6e55a7

View File

@ -1152,6 +1152,27 @@ class JobTemplateSurveyTest(BaseJobTestMixin, django.test.TestCase):
job_extra = json.loads(job.extra_vars)
self.assertTrue("favorite_color" in job_extra)
# launch job template with required survey without providing survey data
with self.current_user(self.user_sue):
self.post(url, json.loads(TEST_SIMPLE_REQUIRED_SURVEY), expect=200)
response = self.get(launch_url)
self.assertTrue('favorite_color' in response['variables_needed_to_start'])
response = self.post(launch_url, dict(extra_vars=dict()), expect=400)
# Note: The below assertion relies on how survey_variable_validation() crafts
# the error message
self.assertIn("'favorite_color' value missing", response['variables_needed_to_start'])
# launch job template with required survey without providing survey data and without
# even providing extra_vars
with self.current_user(self.user_sue):
self.post(url, json.loads(TEST_SIMPLE_REQUIRED_SURVEY), expect=200)
response = self.get(launch_url)
self.assertTrue('favorite_color' in response['variables_needed_to_start'])
response = self.post(launch_url, {}, expect=400)
# Note: The below assertion relies on how survey_variable_validation() crafts
# the error message
self.assertIn("'favorite_color' value missing", response['variables_needed_to_start'])
with self.current_user(self.user_sue):
response = self.post(url, json.loads(TEST_SIMPLE_NONREQUIRED_SURVEY), expect=200)
response = self.get(launch_url)