コード例 #1
0
 def test_time(self):
     test = Create('aquiz', 3)
     test.add_start_time(2020, 1, 1)
     valid = False
     if test.quiz.start_time != None:
         valid = True
     self.assertTrue(valid)
コード例 #2
0
 def test_bad_time(self):
     test = Create('aquiz', 3)
     valid = True
     try:
         test.add_start_time(0, 0, 0)
     except ValueError:
         valid = False
     self.assertFalse(valid)
コード例 #3
0
 def test_time_limit_bad(self):
     '''Test if time limit is set to invalid int.'''
     test = Create('aquiz', 3)
     test.add_time_limit(0)
     valid = False
     if test.quiz.time_limit >=  0:
         valid = True
     self.assertTrue(valid)
コード例 #4
0
 def test_answer_in_choices(self):
     test = Create('aquiz', 3)
     test.add_question("What colour is the sky?", 1, {"B": "BLUE"}, {
         "A": "RED",
         "B": "BLUE",
         "C": "GREEN"
     })
     self.assertTrue(test.quiz.questions[0].answers["B"] ==
                     test.quiz.questions[0].choices["B"])
コード例 #5
0
 def test_end_after_start(self):
     '''Test if the quiz begins before it ends.'''
     test = Create('aquiz', 3)
     test.add_start_time(2020, 3, 3)
     test.add_end_time(2019, 3, 3)
     valid = True
     if test.quiz.start_time > test.quiz.end_time:
         valid = True
     else:
         valid = False
     self.assertTrue(valid)
コード例 #6
0
 def test_answer_in_choices(self):
     test = Create('aquiz', 3)
     test.add_question('What colour is the sky?', 1, {'B':'BLUE'}, {'A':'RED', 'B':'BLUE', 'C':'GREEN'})
     self.assertTrue(test.quiz.questions[0].answers['B'] == test.quiz.questions[0].choices['B'])
コード例 #7
0
 def test_question_options_not_empty(self):
     '''Test if the question is added to the list.'''
     test = Create('aquiz', 3)
     test.add_question('What colour is the sky?', 1,{}, {})
     self.assertFalse(test.quiz.questions[0].answers)
コード例 #8
0
 def test_time_limit(self):
     test = Create('aquiz', 3)
     test.add_time_limit(30)
     self.assertEqual(test.quiz.time_limit, 30)
コード例 #9
0
 def test_quiz_num(self):
     '''Test if number of attempts is set properly.'''
     test = Create('aquiz', 3)
     self.assertEqual(test.quiz.attempts_permitted, 3)
コード例 #10
0
 def test_quiz_name(self):
     '''Test if name attribute is set.'''
     test = Create('aquiz', 3)
     self.assertEqual(test.quiz.name, 'aquiz')
コード例 #11
0
 def test_is_quiz_object(self):
     '''Test if wrapper creates a quiz object.'''
     test = Create('aquiz', 3)
     self.assertIsInstance(test.quiz, Quiz, msg='creating real quiz objects.')
コード例 #12
0
 def test_question_options_not_empty(self):
     """Test if the question is added to the list."""
     test = Create("aquiz", 3)
     test.add_question("What colour is the sky?", 1, {}, {})
     self.assertFalse(test.quiz.questions[0].answers)
コード例 #13
0
 def test_quiz_name(self):
     """Test if name attribute is set."""
     test = Create('aquiz', 3)
     self.assertEqual(test.quiz.name, "aquiz")
コード例 #14
0
 def test_is_quiz_object(self):
     """Test if wrapper creates a quiz object."""
     test = Create('aquiz', 3)
     self.assertIsInstance(test.quiz,
                           Quiz,
                           msg="creating real quiz objects.")