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)
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)
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)
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)
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)
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)
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)
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()
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'])
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)
def test_average_mark_not_string(self): result = StudentMarks([2, 3]).average_of_marks() self.assertNotIsInstance(result, str)
def test_correct_amount(self): result = StudentMarks([2, 3]).amount_of_marks() self.assertEqual(result, 2)
def test_correct_average_mark(self): result = StudentMarks([2, 3]).average_of_marks() self.assertEqual(2.5, result)
def test_average_mark_not_negative(self): result = StudentMarks([2, 3]).average_of_marks() self.assertGreaterEqual(result, 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])
def test_return_error_message_if_add_negative_marks(self): sidorov = StudentMarks([3, 3, 4, 3]) self.assertRaises(ValueError, sidorov.add_new_marks, [-2])
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)
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)
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)