Example #1
0
 def test_answers_correct_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"],
             'correct': None
         })
Example #2
0
 def test_alternatives_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': [1, "2"],
             'correct': 1
         })
Example #3
0
 def test_alternatives_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", ""],
             'correct': 1
         })
Example #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
         })
Example #5
0
 def test_missing_answer(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value'})
Example #6
0
 def test_invalid(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'key': 'value'})
Example #7
0
 def test_empty_string(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': ''})
Example #8
0
 def test_answers_too_few_answers(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1]})
Example #9
0
 def test_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({})
Example #10
0
 def test_answers_missing_correct(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({
             'question': 'value',
             'answers': ["1", "2"]
         })
Example #11
0
 def test_empty_string(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': ''})
Example #12
0
 def test_boolean_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answer': None})
Example #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})
Example #14
0
 def test_correct_answers_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': [None]})
Example #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})
Example #16
0
 def test_alternatives_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", ""], 'correct': 1})
Example #17
0
 def test_alternatives_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1, "2"], 'correct': 1})
Example #18
0
 def test_answers_missing_correct(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': ["1", "2"]})
Example #19
0
 def test_answers_invalid_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': 1})
Example #20
0
 def test_invalid(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'key': 'value'})
Example #21
0
 def test_answers_too_few_answers(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': [1]})
Example #22
0
 def test_boolean_wrong_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answer': None})
Example #23
0
 def test_missing_answer(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value'})
Example #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
     })
Example #25
0
 def test_empty(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({})
Example #26
0
 def test_answers_invalid_type(self):
     with self.assertRaises(importer.ValidationError):
         importer.validate_question({'question': 'value', 'answers': 1})