def test_file_write(self):
        crud.file_write([])
        student_1 = student.Student("test", "test", "t11111111", True, [])
        student_2 = student.Student("test", "test", "t22222222", True, [])

        crud.file_write([student_1, student_2])
        self.assertTrue(
            crud.file_read()[0].get_student_number() == "T11111111"
            and crud.file_read()[1].get_student_number() == "T22222222")
        crud.file_write([])
    def test_file_read(self):
        student_1 = student.Student("test", "test", "t11111111", True, [])
        student_2 = student.Student("test", "test", "t22222222", True, [])

        crud.file_write([student_1, student_2])
        students = crud.file_read()
        self.assertTrue(student_1.get_student_number() in students[0].get_student_number()
                        and student_2.get_student_number() in students[1].get_student_number())
        crud.file_write([])
 def test_exclude_student(self, mock_file, mock_data):
     list_of_students = [
         Student("Linh", "Truong", "A01081792", True),
         Student("Dave", "Mundy", "A00000000", False),
         Student("Angus", "Mundy", "A12345678", True),
         Student("Ben", "Spratt", "A77886655", False)
     ]
     exclude_student(list_of_students)
     self.assertEqual(str(list_of_students), str(file_read()))
Example #4
0
 def test_file_read_information(self, mock_file):
     list_students = []
     student_instance = Student("Remy", "Truong", "A09876543", False)
     student_instance.update_grades(49)
     student_instance.update_grades(60)
     student_instance.update_grades(57)
     student_instance_1 = Student("May", "Chau", "A98898999", True)
     student_instance_1.update_grades(80)
     student_instance_1.update_grades(90)
     student_instance_2 = Student("Linh", "Truong", "A01081792", True)
     list_students.append(student_instance)
     list_students.append(student_instance_1)
     list_students.append(student_instance_2)
     actual = file_read()
     self.assertEqual(str(list_students), str(actual))
Example #5
0
 def test_file_read_objects_are_class_student(self):
     with patch('builtins.open', mock_open(read_data=mock_file)):
         for student in file_read():
             self.assertIsInstance(student, Student)
Example #6
0
 def test_file_read_return_list_of_objects(self):
     with patch('builtins.open', mock_open(read_data=mock_file)):
         for student in file_read():
             self.assertIsInstance(student, object)
Example #7
0
 def test_file_read_return_type(self):
     with patch('builtins.open', mock_open(read_data=mock_file)):
         self.assertIsInstance(file_read(), list)
Example #8
0
 def test_file_read_list(self, mock_file):
     student_instance = Student("First", "Last", "A12345678", True)
     student_instance.update_grades(49)
     self.assertEqual(type(file_read()), list)
Example #9
0
 def test_file_read_values(self, mock_file):
     student_list = file_read()
     self.assertEqual(student_list[0].__str__(), "Remy Truong A00000000 True 63")
Example #10
0
 def test_file_read_len(self, mock_file):
     actual = file_read()
     self.assertEqual(len(actual), 2)
Example #11
0
 def test_file_read_content(self, mock_file):
     student_instance = Student("First", "Last", "A12345678", True)
     student_instance.update_grades(49)
     actual = file_read()
     self.assertEqual(str([student_instance]), str(actual))
Example #12
0
 def test_delete_student(self, mock_input):
     crud.file_write([])
     crud.add_student()
     crud.delete_student()
     self.assertEqual(0, len(crud.file_read()))
 def test_add_student_successfully(self, mock_input):
     crud.add_student()
     self.assertEqual("T12345678", crud.file_read()[0].get_student_number())
     crud.file_write([])
Example #14
0
 def test_file_append_student(self):
     crud.file_write([])
     crud.file_append_student(
         student.Student("test", "test", "t12345678", True, []))
     self.assertEqual(crud.file_read()[0].get_student_number(), "T12345678")
     crud.file_write([])
 def test_file_write_blank(self):
     crud.file_write([])
     self.assertEqual(0, len(crud.file_read()))
 def test_add_grade_successfully(self, mock_input):
     crud.file_write([])
     crud.add_student()
     crud.add_grade()
     self.assertEqual(42.0, crud.file_read()[0].get_final_grades()[0])
     crud.file_write([])