Commit 2ed1e3d8 by Bridger Maxwell

Added tests for survey question format.

parent 1617c71e
......@@ -6,11 +6,28 @@ Replace this with more appropriate tests for your application.
"""
from django.test import TestCase
from survey_questions import exit_survey_questions
class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
class ExitSurveyTest(TestCase):
def test_unique_names(self):
question_names = set()
for question in exit_survey_questions['common_questions'] + exit_survey_questions['random_questions']:
name = question['question_name']
self.assertFalse( name in question_names, "There is a duplicate of name " + name )
question_names.add(name)
def test_question_format(self):
for question in exit_survey_questions['common_questions'] + exit_survey_questions['random_questions']:
self.assertTrue( 'question_name' in question, "All questions need a question_name. Failed on: " + str(question) )
self.assertTrue( 'label' in question, "All questions need a label. Failed on: " + str(question) )
question_type = question['type']
if question_type == 'checkbox' or question_type == 'short_field':
# No other required fields
pass
elif question_type == 'radio' or question_type == 'select_many':
self.assertTrue( 'choices' in question, "All radio/select_many questions need choices. Failed on: " + str(question) )
else:
self.assertTrue(False, "Found illegal question type. Failed on: " + str(question) )
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment