예제 #1
0
 def test_number_of_failing_students_among_successful_student(self):
     ivanov = StudentMarks([2, 3, 4, 5])
     smirnov = StudentMarks([4, 3, 4, 4, 5])
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     journal = Register([ivanov, smirnov, sidorov])
     result = journal.count_of_losers()
     self.assertEqual(0, result)
예제 #2
0
 def test_number_of_excellent_students_among_failing_student(self):
     ivanov = StudentMarks([2, 3, 2])
     smirnov = StudentMarks([2, 2, 2, 2, 5])
     sidorov = StudentMarks([3, 3, 4, 3])
     journal = Register([ivanov, smirnov, sidorov])
     result = journal.count_of_excellent()
     self.assertEqual(0, result)
예제 #3
0
 def test_number_of_excellent_student(self):
     ivanov = StudentMarks([5, 5, 4, 5, 5])
     smirnov = StudentMarks([2, 3])
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     petrov = StudentMarks([2, 4])
     journal = Register([ivanov, smirnov, sidorov, petrov])
     result = journal.count_of_excellent()
     self.assertEqual(2, result)
예제 #4
0
 def test_surnames_of_excellent_students(self):
     ivanov = StudentMarks([5, 5, 4, 5, 5])
     smirnov = StudentMarks([2, 3])
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     petrov = StudentMarks([2, 4])
     journal = Register([ivanov, smirnov, sidorov, petrov])
     result = journal.surnames_of_excellent_students()
     self.assertEqual([ivanov, sidorov], result)
예제 #5
0
 def test_number_of_failing_student(self):
     ivanov = StudentMarks([2, 2, 2, 2])
     smirnov = StudentMarks([2, 3, 2, 2, 3])
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     petrov = StudentMarks([2, 3, 2])
     journal = Register([ivanov, smirnov, sidorov, petrov])
     result = journal.count_of_losers()
     self.assertEqual(3, result)
예제 #6
0
 def test_number_of_successful_student(self):
     ivanov = StudentMarks([5, 5, 4, 5, 5])
     smirnov = StudentMarks([2, 3])
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     petrov = StudentMarks([2, 4])
     journal = Register([ivanov, smirnov, sidorov, petrov])
     result = journal.count_of_students_who_successfully_pass()
     self.assertEqual(2, result)
예제 #7
0
 def test_surnames_of_successful_students(self):
     ivanov = StudentMarks([5, 5, 4, 5, 5])
     smirnov = StudentMarks([2, 3, 5, 5, 5, 5, 5])
     sidorov = StudentMarks([3, 5, 4, 3, 3, 3])
     petrov = StudentMarks([2, 4])
     journal = Register([ivanov, smirnov, sidorov, petrov])
     result = journal.students_who_successfully_pass()
     self.assertEqual([ivanov, smirnov, sidorov], result)
예제 #8
0
    def validate_text(self):
        try:
            marks1 = parser_marks(self.marks1_txt)
            self.stud1 = StudentMarks(marks1)
            marks2 = parser_marks(self.marks2_txt)
            self.stud2 = StudentMarks(marks2)
            marks3 = parser_marks(self.marks3_txt)
            self.stud3 = StudentMarks(marks3)

            self.set_btn_enabled()
            self.logger.log('Marks was successfully written: %s, %s, %s' %
                            (marks1, marks2, marks3))
        except:
            self.set_btn_disabled()
            self.logger.log('Invalid input!')
 def validate_text(self):
     try:
         self.marks1 = self.parser_marks(self.txt_from_stud1_txt)
         stud1 = StudentMarks(self.marks1)
         self.marks2 = self.parser_marks(self.txt_from_stud2_txt)
         stud2 = StudentMarks(self.marks2)
         self.marks3 = self.parser_marks(self.txt_from_stud3_txt)
         stud3 = StudentMarks(self.marks3)
     except:
         self.set_btn_disabled()
     else:
         self.set_btn_enabled()
         journal = Register([stud1, stud2, stud3])
         self.count_of_losers = journal.count_of_losers()
         self.count_of_students_who_successfully_pass = journal.count_of_students_who_successfully_pass(
         )
         self.count_of_excellent = journal.count_of_excellent()
예제 #10
0
 def test_return_error_message_if_add_invalid_type_of_marks(self):
     sidorov = StudentMarks([3, 3, 4, 3])
     self.assertRaises(TypeError, sidorov.add_new_marks, ['two', 'three'])
예제 #11
0
 def test_number_of_success_students_not_negative(self):
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     journal = Register([sidorov])
     result = journal.count_of_students_who_successfully_pass()
     self.assertGreaterEqual(result, 0)
예제 #12
0
 def test_average_mark_not_string(self):
     result = StudentMarks([2, 3]).average_of_marks()
     self.assertNotIsInstance(result, str)
예제 #13
0
 def test_correct_amount(self):
     result = StudentMarks([2, 3]).amount_of_marks()
     self.assertEqual(result, 2)
예제 #14
0
 def test_correct_average_mark(self):
     result = StudentMarks([2, 3]).average_of_marks()
     self.assertEqual(2.5, result)
예제 #15
0
 def test_average_mark_not_negative(self):
     result = StudentMarks([2, 3]).average_of_marks()
     self.assertGreaterEqual(result, 0)
예제 #16
0
 def test_return_error_message_if_add_mark_greater_5(self):
     sidorov = StudentMarks([3, 3, 4, 3])
     self.assertRaises(ValueError, sidorov.add_new_marks, [3, 7, 5])
예제 #17
0
 def test_return_error_message_if_add_negative_marks(self):
     sidorov = StudentMarks([3, 3, 4, 3])
     self.assertRaises(ValueError, sidorov.add_new_marks, [-2])
예제 #18
0
 def test_number_of_excellent_students_not_negative(self):
     sidorov = StudentMarks([4, 5, 4, 5, 5, 5])
     journal = Register([sidorov])
     result = journal.count_of_excellent()
     self.assertGreaterEqual(result, 0)
예제 #19
0
 def test_add_two_marks_to_a_student(self):
     sidorov = StudentMarks([3, 3, 4, 3])
     sidorov.add_new_marks([5, 4])
     self.assertEqual([3, 3, 4, 3, 5, 4], sidorov.marks)
예제 #20
0
 def test_correct_add_mark_to_a_student(self):
     sidorov = StudentMarks([3, 3, 4, 3])
     sidorov.add_new_marks([5])
     self.assertEqual([3, 3, 4, 3, 5], sidorov.marks)