def test_question_is_subquestion_if_parent_is_given(self): question_2 = Question.objects.create(text="This is a question", answer_type="number", order=2) subquestion = Question(text="Specify others", answer_type=Question.TEXT, parent=question_2) subquestion.save() self.assertEqual(False, question_2.subquestion) self.assertEqual(True, subquestion.subquestion)
def test_fields(self): ss_content = Question() fields = [str(item.attname) for item in ss_content._meta.fields] self.assertEqual(9, len(fields)) for field in [ 'id', 'created', 'modified', 'identifier', 'text', 'answer_type', 'mandatory', 'qset_id', 'response_validation_id' ]: self.assertIn(field, fields)
def test_variable_name_should_be_unique(self): question = Question.objects.create(identifier='143.1', text="This is a question", answer_type='Text Answer', group=self.household_member_group, batch=self.batch, module=self.question_mod) duplicate_question = Question(identifier='143.1', text="This is a question", answer_type='Text Answer', group=self.household_member_group, batch=self.batch, module=self.question_mod) self.assertRaises(IntegrityError, duplicate_question.save)
def zombie_questions(self): return Question.zombies(self)