More unit testing

This commit is contained in:
2013-08-25 21:10:22 +10:00
parent 5ab0b8c837
commit ff050cc141
4 changed files with 36 additions and 9 deletions

View File

@@ -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)