コード例 #1
0
 def test_Instructor(self):
     '''testing the instructor class'''
     directory: str = '/Users/tylermarchiano/Documents/Stevens/SSW810/Student-Repository/instructors.txt'
     
     instructors_file: List[str] = list(file_reader(directory, 3, sep='\t', header=True))
     instructors_dict: Dict[str, Instructor] = dict()
     for cwid, name, department in instructors_file:
         instructors_dict[cwid] = Instructor(cwid, name, department)
     
     num_instructors: int = 3
     name_instructor98762: str = "Hawking, S"
     name_instructor98764: str = "Cohen, R"
     name_instructor98763: str = "Rowland, J"
     department_instructor98763: str = 'SFEN'
     department_instructor98764: str = 'SFEN'
     department_instructor98762: str = 'CS'
     
     
     self.assertEqual(num_instructors, len(list(instructors_dict.values())))
     self.assertEqual(name_instructor98762, instructors_dict['98762'].name)
     self.assertEqual(name_instructor98764, instructors_dict['98764'].name)
     self.assertEqual(name_instructor98763, instructors_dict['98763'].name)
     self.assertEqual(department_instructor98763, instructors_dict['98763'].department)
     self.assertEqual(department_instructor98764, instructors_dict['98764'].department)
     self.assertEqual(department_instructor98762, instructors_dict['98762'].department)
コード例 #2
0
    def read_instructors(self) -> None:
        '''read the instructors.txt file, creating a new Student for each line in the file'''
        file_path: str = path.join(self.path, 'instructors.txt')
        try:
            instructors_file: List[str] = list(
                file_reader(file_path, 3, sep='\t', header=True))
        except:
            raise FileNotFoundError(
                f"Can't find instructors.txt in the given directory")

        for cwid, name, department in instructors_file:
            self.instructors[cwid] = Instructor(cwid, name, department)
コード例 #3
0
    def read_students(self) -> None:
        '''read the students.txt file, creating a new Student for each line in the file'''
        file_path: str = path.join(self.path, 'students.txt')
        try:
            students_file: List[str] = list(
                file_reader(file_path, 3, sep='\t', header=True))
        except:
            raise FileNotFoundError(
                f"Can't find students.txt in the given directory")

        for cwid, name, major in students_file:
            self.students[cwid] = Student(cwid, name, self.majors[major])
コード例 #4
0
    def read_majors(self) -> None:
        '''reads the majors.txt file and processes all of that information. 
        Create a new object of type Major for each major'''
        file_path: str = path.join(self.path, 'majors.txt')
        try:
            majors_file: List[str] = list(
                file_reader(file_path, 3, sep='\t', header=True))
        except:
            raise FileNotFoundError(
                f"Can't find majors.txt in the given directory")

        for major, flag, course in majors_file:
            if major not in self.majors:
                self.majors[major] = Major(major)
                self.majors[major].add_course(flag, course)
            else:
                self.majors[major].add_course(flag, course)
コード例 #5
0
    def read_grades(self) -> None:
        '''reads the grades.txt file and processes all of that information. 
        assigns students courses and grades. Assigns professors courses '''
        file_path: str = path.join(self.path, 'grades.txt')
        try:
            grades_file: List[str] = list(
                file_reader(file_path, 4, sep='\t', header=True))
        except:
            raise FileNotFoundError(
                f"Can't find grades.txt in the given directory")

        for s_cwid, course, grade, p_cwid in grades_file:
            #add the course and grade for the student
            self.students[s_cwid].add_course(course, grade)

            #add the course to the professor if it doesn't exist already and increment the count of the students
            self.instructors[p_cwid].add_course(course)
コード例 #6
0
 def test_student(self):
     '''testing the student class'''
     directory: str = '/Users/tylermarchiano/Documents/Stevens/SSW810/Student-Repository/students.txt'
     
     students_file: List[str] = list(file_reader(directory, 3, sep='\t', header=True))
     students_dict: Dict[str, Student] = dict()
     for cwid, name, major in students_file:
         students_dict[cwid] = Student(cwid, name, major)
     
     num_students: int = 4
     name_student10103: str = "Jobs, S"
     name_student10115: str = "Bezos, J"
     major_student10183: str = 'SFEN'
     major_student11714: str = 'CS'
     
     
     self.assertEqual(num_students, len(list(students_dict.values())))
     self.assertEqual(name_student10103, students_dict['10103'].name)
     self.assertEqual(name_student10115, students_dict['10115'].name)
     self.assertEqual(major_student10183, students_dict['10183'].major)
     self.assertEqual(major_student11714, students_dict['11714'].major)
コード例 #7
0
 def test_major(self):
     '''testing the major class'''
     directory: str = '/Users/tylermarchiano/Documents/Stevens/SSW810/Student-Repository/majors.txt'
     
     majors_file: List[str] = list(file_reader(directory, 3, sep='\t', header=True))
     majors_dict: Dict[str, Major] = dict()
     for major, flag, course in majors_file:
         if major not in majors_dict:
             majors_dict[major] = Major(major)
             majors_dict[major].add_course(flag, course)
         else:
             majors_dict[major].add_course(flag, course)
 
     SFEN_required: List[str] = ['SSW 540', 'SSW 555', 'SSW 810']
     SFEN_electives: List[str] = ['CS 501', 'CS 546'] 
     CS_required: List[str] = ['CS 546', 'CS 570']  
     CS_electives: List[str] = ['SSW 565', 'SSW 810']
     
     self.assertEqual(SFEN_required, sorted(majors_dict['SFEN'].required_courses))
     self.assertEqual(SFEN_electives, sorted(majors_dict['SFEN'].electives))
     self.assertEqual(CS_required, sorted(majors_dict['CS'].required_courses))
     self.assertEqual(CS_electives, sorted(majors_dict['CS'].electives))