示例#1
0
 def test_answers_correct_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"],
             'correct': None
         })
示例#2
0
 def test_alternatives_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': [1, "2"],
             'correct': 1
         })
示例#3
0
 def test_alternatives_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", ""],
             'correct': 1
         })
示例#4
0
 def test_correct_answers_out_of_bounds(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"],
             'correct': 3
         })
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"],
             'correct': -1
         })
示例#5
0
 def test_missing_answer(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value'})
示例#6
0
 def test_invalid(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'key': 'value'})
示例#7
0
 def test_empty_string(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': ''})
示例#8
0
 def test_answers_too_few_answers(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1]})
示例#9
0
 def test_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({})
示例#10
0
 def test_answers_missing_correct(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"]
         })
示例#11
0
 def test_empty_string(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': ''})
示例#12
0
 def test_boolean_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answer': None})
示例#13
0
 def test_valid(self):
     importer.validate_question({'question': 'value', 'answer': True})
     importer.validate_question({'question': 'value', 'answer': False})
     importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': 0})
     importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': 1})
     importer.validate_question({'question': 'value', 'answers': ["1", "2", "3"], 'correct': 1})
     importer.validate_question({'question': 'value', 'answers': ["1", "2", "3"], 'correct': 1})
示例#14
0
 def test_correct_answers_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': [None]})
示例#15
0
 def test_correct_answers_out_of_bounds(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': 3})
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': -1})
示例#16
0
 def test_alternatives_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", ""], 'correct': 1})
示例#17
0
 def test_alternatives_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1, "2"], 'correct': 1})
示例#18
0
 def test_answers_missing_correct(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"]})
示例#19
0
 def test_answers_invalid_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': 1})
示例#20
0
 def test_invalid(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'key': 'value'})
示例#21
0
 def test_answers_too_few_answers(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1]})
示例#22
0
 def test_boolean_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answer': None})
示例#23
0
 def test_missing_answer(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value'})
示例#24
0
 def test_valid(self):
     importer.validate_question({'question': 'value', 'answer': True})
     importer.validate_question({'question': 'value', 'answer': False})
     importer.validate_question({
         'question': 'value',
         'answers': ["1", "2"],
         'correct': 0
     })
     importer.validate_question({
         'question': 'value',
         'answers': ["1", "2"],
         'correct': 1
     })
     importer.validate_question({
         'question': 'value',
         'answers': ["1", "2", "3"],
         'correct': 1
     })
     importer.validate_question({
         'question': 'value',
         'answers': ["1", "2", "3"],
         'correct': 1
     })
示例#25
0
 def test_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({})
示例#26
0
 def test_answers_invalid_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': 1})