More unit testing
This commit is contained in:
@@ -38,8 +38,30 @@ class ModelsTest(TestCase):
|
||||
self.assertEqual("Test", testanswer.__unicode__())
|
||||
|
||||
def test_no_correct_answers(self):
|
||||
testquestion = Question(text="Test")
|
||||
testquestion = Question(text="Test", id=1)
|
||||
|
||||
Answer(text="Test", correct=False, question=testquestion)
|
||||
answer = Answer(text="Test", correct=False, question=testquestion)
|
||||
answer2 = Answer(text="Test2", correct=False, question=testquestion)
|
||||
|
||||
testquestion.answers = [answer, answer2, ]
|
||||
|
||||
self.assertEqual(len(testquestion.correct_answers()), 0)
|
||||
|
||||
def test_correct_answers(self):
|
||||
testquestion = Question(text="Test", id=1)
|
||||
|
||||
answer = Answer(text="Test", correct=True, question=testquestion)
|
||||
answer2 = Answer(text="Test2", correct=False, question=testquestion)
|
||||
testquestion.answers = [answer, answer2]
|
||||
|
||||
self.assertEqual(len(testquestion.correct_answers()), 1)
|
||||
|
||||
def test_multiple_correct_answers(self):
|
||||
testquestion = Question(text="Test", id=1)
|
||||
|
||||
answer = Answer(text="Test", correct=True, question=testquestion)
|
||||
answer2 = Answer(text="Test2", correct=False, question=testquestion)
|
||||
answer3 = Answer(text="Test3", correct=True, question=testquestion)
|
||||
testquestion.answers = [answer, answer2, answer3, ]
|
||||
|
||||
self.assertEqual(len(testquestion.correct_answers()), 2)
|
||||
|
||||
Reference in New Issue
Block a user