def test_answers_correct_wrong_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({ 'question': 'value', 'answers': ["1", "2"], 'correct': None })
def test_alternatives_wrong_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({ 'question': 'value', 'answers': [1, "2"], 'correct': 1 })
def test_alternatives_empty(self): with self.assertRaises(importer.ValidationError): importer.validate_question({ 'question': 'value', 'answers': ["1", ""], 'correct': 1 })
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 })
def test_missing_answer(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value'})
def test_invalid(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'key': 'value'})
def test_empty_string(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': ''})
def test_answers_too_few_answers(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': [1]})
def test_empty(self): with self.assertRaises(importer.ValidationError): importer.validate_question({})
def test_answers_missing_correct(self): with self.assertRaises(importer.ValidationError): importer.validate_question({ 'question': 'value', 'answers': ["1", "2"] })
def test_boolean_wrong_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answer': None})
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})
def test_correct_answers_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': ["1", "2"], 'correct': [None]})
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})
def test_alternatives_empty(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': ["1", ""], 'correct': 1})
def test_alternatives_wrong_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': [1, "2"], 'correct': 1})
def test_answers_missing_correct(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': ["1", "2"]})
def test_answers_invalid_type(self): with self.assertRaises(importer.ValidationError): importer.validate_question({'question': 'value', 'answers': 1})
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 })