22from django .utils import timezone
33from ..models .quiz_models import Question , Tag , Answer
44
5- import datetime
5+ MC = Question .QuestionType .MULTICHOICE
6+ NA = Question .QuestionType .NUMERIC
7+ SA = Question .QuestionType .SHORT_ANSWER
68
79
810class QuestionTestCase (TestCase ):
911 def setUp (self ):
1012 self .creation_time = timezone .now ()
13+
1114 Question .objects .create (text = "Test multiple choice question" ,
12- question_type =
13- Question .QuestionType .MULTICHOICE )
15+ question_type = MC )
1416 Question .objects .create (text = "Test numerical answer question" ,
15- question_type = Question . QuestionType . NUMERIC )
17+ question_type = NA )
1618 Question .objects .create (text = "Test short answer question" ,
17- question_type =
18- Question .QuestionType .SHORT_ANSWER )
19+ question_type = SA )
1920
2021 def test_text (self ):
2122 mc = Question .objects .get (text = "Test multiple choice question" )
@@ -51,8 +52,7 @@ def test_date_created(self):
5152class TagTestCase (TestCase ):
5253 def setUp (self ):
5354 q = Question .objects .create (text = "This is a physics question" ,
54- question_type =
55- Question .QuestionType .NUMERIC )
55+ question_type = NA )
5656 t = Tag .objects .create (name = "Unit 3 Physics" )
5757 q .tag_set .add (t )
5858
@@ -67,8 +67,7 @@ def test(self):
6767class AnswerTestCase (TestCase ):
6868 def setUp (self ):
6969 q = Question .objects .create (text = "Question?" ,
70- question_type =
71- Question .QuestionType .SHORT_ANSWER )
70+ question_type = SA )
7271 Answer .objects .create (text = "Answer!" , question = q , is_correct = True )
7372
7473 def test (self ):
@@ -80,4 +79,3 @@ def test(self):
8079 self .assertTrue (a .is_correct )
8180
8281 self .assertEquals (a .question , q )
83-
0 commit comments