コード例 #1
0
    def test_parse_course_fills_instructor_and_meeting(self):
        """ Tests if parse_course also adds an instructor and meeting to the database """

        # Arrange
        instructor_id = "John M. Moore"
        instructor_email = "*****@*****.**"
        instructor = Instructor(id=instructor_id,
                                email_address=instructor_email)

        meeting_id = 4972230
        crn = 12323
        building = "ZACH"
        begin_time = datetime.time(13, 50, 0)
        end_time = datetime.time(14, 40, 0)
        meeting_type = "LEC"
        meeting_days = [True, False, True, False, True, False, False]
        section = Section(id=497223,
                          subject="CSCE",
                          course_num=121,
                          section_num=501,
                          term_code=0,
                          crn=crn,
                          min_credits=0,
                          current_enrollment=0,
                          max_enrollment=0,
                          instructor=instructor,
                          asynchronous=False)

        #Act
        course, instructor, (section,
                             meetings) = parse_course(self.csce_section_json,
                                                      set(), set())
        instructor.save()
        section.save()
        Meeting.objects.bulk_create(meetings)
        course.save()

        # Assert
        Instructor.objects.get(id=instructor_id,
                               email_address=instructor_email)
        Meeting.objects.get(id=meeting_id,
                            building=building,
                            meeting_days=meeting_days,
                            start_time=begin_time,
                            end_time=end_time,
                            meeting_type=meeting_type,
                            section=section)
コード例 #2
0
    def test_parse_course_accept_alphanumeric_course_num(self):
        """ Tests if parse_course accepts alphanumberic course_num field (eg. 7500S) """

        # Arrange
        subject = "LAW"
        course_num = "7500S"
        title = "SPORTS LAW"
        credit_hours = 3
        term = "201931"

        # Act
        course, *_ = parse_course(self.law_section_json, set(), set())
        course.save()

        # Assert
        Course.objects.get(dept=subject,
                           course_num=course_num,
                           title=title,
                           credit_hours=credit_hours,
                           term=term)
コード例 #3
0
    def test_parse_course_does_save_model(self):
        """ Tests if parse_course saves the course to the database correctly """

        # Arrange
        subject = "CSCE"
        course_num = "121"
        title = "INTRO PGM DESIGN CONCEPT"
        credit_hours = 4
        term = "202011"

        # Act
        course, *_ = parse_course(self.csce_section_json, set(), set())
        course.save()

        # Assert
        Course.objects.get(dept=subject,
                           course_num=course_num,
                           title=title,
                           credit_hours=credit_hours,
                           term=term)
コード例 #4
0
    def test_parse_course_removes_hnr(self):
        """ Tests if parse_course removes the "HNR-" in front of honors sections """

        # Arrange
        subject = "ACCT"
        course_num = "229"
        # Actual title: "HNR-INTRO ACCOUNTING"
        correct_title = "INTRO ACCOUNTING"
        credit_hours = 3
        term = "201931"

        # Act
        course, *_ = parse_course(self.acct_section_json, set(), set())
        course.save()

        # Assert
        Course.objects.get(dept=subject,
                           course_num=course_num,
                           title=correct_title,
                           credit_hours=credit_hours,
                           term=term)
コード例 #5
0
    def test_parse_course_removes_html_escapes(self):
        """ Tests if parse_course removes escaped HTML characters, like &
            from the title
        """

        # Arrange
        subject = "POLS"
        course_num = "207"
        # Actual title: "STATE & LOCAL GOVT"
        correct_title = "STATE & LOCAL GOVT"
        credit_hours = 3
        term = "201931"

        # Act
        course, *_ = parse_course(self.pols_section_json, set(), set())
        course.save()

        # Assert
        Course.objects.get(dept=subject,
                           course_num=course_num,
                           title=correct_title,
                           credit_hours=credit_hours,
                           term=term)