Esempio n. 1
0
 def test_question_uid_is_unique(self):
     a_question = Question.objects.create(
         text='Uganda Revision 2014 what what?',
         UID='abc123',
         answer_type='Text')
     question_with_same_uid = Question(text='haha',
                                       UID='abc123',
                                       answer_type='Text')
     self.assertRaises(IntegrityError, question_with_same_uid.save)
Esempio n. 2
0
 def test_question_fields(self):
     question = Question()
     fields = [str(item.attname) for item in question._meta.fields]
     self.assertEqual(11, len(fields))
     for field in [
             'id', 'created', 'modified', 'text', 'instructions', 'UID',
             'answer_type', 'is_core', 'is_primary', 'is_required',
             'export_label'
     ]:
         self.assertIn(field, fields)
Esempio n. 3
0
 def test_child_question_uid_is_parent_question_uid(self):
     parent_question = Question.objects.create(text='question text', UID='abc123', answer_type='Text')
     child_question_with_same_uid = Question(text='revised text', UID='abc123', answer_type='Text', parent=parent_question)
     child_question_with_same_uid.save()
     self.failUnless(child_question_with_same_uid.id)
Esempio n. 4
0
 def test_get_next_uid_given_given_largest_uid_is_9th(self):
     Question.objects.create(text='question 3', UID='C00009', answer_type='Number')
     self.assertEqual('00010', Question.next_uid())
Esempio n. 5
0
 def test_get_next_uid_given_given_largest_uid_question(self):
     self.assertEqual('00004', Question.next_uid())
Esempio n. 6
0
 def test_get_next_uid_given_given_largest_uid_is_9th(self):
     Question.objects.create(text='question 3',
                             UID='C00009',
                             answer_type='Number')
     self.assertEqual('00010', Question.next_uid())
Esempio n. 7
0
 def test_get_next_uid_given_given_largest_uid_question(self):
     self.assertEqual('00004', Question.next_uid())