コード例 #1
0
    def test__get_meetings_filters_full(self):
        """ Tests that _get_meetings filters sections with no available seats if the
            include_full attribute of the CourseFilter is False
        """
        # Arrange
        course = CourseFilter("CSCE", "121")
        term = "201931"
        include_full = False
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-501
            Meeting(id=40, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[3]),
            Meeting(id=41, meeting_days=[True] * 7, start_time=time(9, 10),
                    end_time=time(10), meeting_type='LAB', section=self.sections[3]),
            # Meetings for CSCE 121-502
            Meeting(id=50, meeting_days=[True] * 7, start_time=time(12, 30),
                    end_time=time(1, 20), meeting_type='LEC', section=self.sections[4]),
            Meeting(id=51, meeting_days=[True] * 7, start_time=time(10),
                    end_time=time(10, 50), meeting_type='LAB', section=self.sections[4]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 502 should be filtered because it has no available seats
        valid_sections = set((4,))
        meetings_for_sections = {4: meetings[0:2]}

        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #2
0
    def test__get_meetings_gets_all_meetings(self):
        """ Tests that _get_meetings gets all sections/meetings for the specified term
            and groups them correctly
        """
        # Arrange
        course = CourseFilter("CSCE", "310")
        term = "201931"
        include_full = True
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 310-501
            Meeting(id=10, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[0]),
            Meeting(id=11, meeting_days=[True] * 7, start_time=time(9),
                    end_time=time(9, 50), meeting_type='LEC', section=self.sections[0]),
            # Meetings for CSCE 310-502
            Meeting(id=20, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[1]),
            Meeting(id=21, meeting_days=[True] * 7, start_time=time(8),
                    end_time=time(8, 50), meeting_type='LAB', section=self.sections[1]),
            # Meetings for CSCE 310-503
            Meeting(id=30, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[2]),
            Meeting(id=31, meeting_days=[True] * 7, start_time=time(8),
                    end_time=time(8, 50), meeting_type='LAB', section=self.sections[2]),
        ]
        Meeting.objects.bulk_create(meetings)
        valid_sections = set((1, 2))
        meetings_for_sections = {1: meetings[0:2], 2: meetings[2:4]}
        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #3
0
    def test__get_meetings_filters_non_web(self):
        """ Tests that _get_meetings filters non-web sections if the web attribute
            of the CourseFilter is 'only'
        """
        # Arrange
        course = CourseFilter("CSCE", "121", web=BasicFilter.ONLY)
        term = "201931"
        include_full = True
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-501
            Meeting(id=40, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[3]),
            Meeting(id=41, meeting_days=[True] * 7, start_time=time(9, 10),
                    end_time=time(10), meeting_type='LAB', section=self.sections[3]),
            # Meetings for CSCE 121-502
            Meeting(id=50, meeting_days=[True] * 7, start_time=time(12, 30),
                    end_time=time(1, 20), meeting_type='LEC', section=self.sections[4]),
            Meeting(id=51, meeting_days=[True] * 7, start_time=time(10),
                    end_time=time(10, 50), meeting_type='LAB', section=self.sections[4]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 501 should be filtered because it isn't a web section
        valid_sections = set((5,))
        meetings_for_sections = {5: meetings[2:]}

        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #4
0
    def test__get_meetings_filters_honors(self):
        """ Tests that _get_meetings filters honors sections if the honors attribute
            of the CourseFilter is 'exclude'
        """
        # Arrange
        course = CourseFilter("CSCE", "121",
                              honors=BasicFilter.EXCLUDE,
                              web=BasicFilter.NO_PREFERENCE)
        term = "201931"
        include_full = True
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-502
            Meeting(id=50, meeting_days=[True] * 7, start_time=time(12, 30),
                    end_time=time(1, 20), meeting_type='LEC', section=self.sections[4]),
            Meeting(id=51, meeting_days=[True] * 7, start_time=time(10),
                    end_time=time(10, 50), meeting_type='LAB', section=self.sections[4]),
            # Meetings for CSCE 121-201
            Meeting(id=60, meeting_days=[True] * 7, start_time=time(12, 30),
                    end_time=time(1, 20), meeting_type='LEC', section=self.sections[5]),
            Meeting(id=61, meeting_days=[True] * 7, start_time=time(10),
                    end_time=time(10, 50), meeting_type='LAB', section=self.sections[5]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 201 should be filtered because it is an honors section
        valid_sections = set((5,))
        meetings_for_sections = {5: meetings[0:2]}

        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #5
0
    def test__get_meetings_filters_section_nums(self):
        """ Tests that _get_meetings filters sections not in the CourseFilter's
            section_nums
        """
        # Arrange
        course = CourseFilter("CSCE", "310", section_nums=[501])
        term = "201931"
        include_full = True
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 310-501
            Meeting(id=10, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[0]),
            Meeting(id=11, meeting_days=[True] * 7, start_time=time(9),
                    end_time=time(9, 50), meeting_type='LEC', section=self.sections[0]),
            # Meetings for CSCE 310-502
            Meeting(id=20, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[1]),
            Meeting(id=21, meeting_days=[True] * 7, start_time=time(8),
                    end_time=time(8, 50), meeting_type='LAB', section=self.sections[1]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 502 should be filtered because it isn't in section_nums
        valid_sections = set((1,))
        meetings_for_sections = {1: meetings[0:2]}
        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #6
0
    def test__get_meetings_handles_unavailability(self):
        """ Tests that _get_meetings filters sections with meetings conflicting
            with the given unavailable_times
        """
        # Arrange
        course = CourseFilter("CSCE", "310")
        term = "201931"
        include_full = True
        unavailable_times = (UnavailableTime(time(8), time(8, 30), 4),)
        meetings = [
            # Meetings for CSCE 310-501
            Meeting(id=10, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[0]),
            Meeting(id=11, meeting_days=[True] * 7, start_time=time(9),
                    end_time=time(9, 50), meeting_type='LEC', section=self.sections[0]),
            # Meetings for CSCE 310-502
            Meeting(id=20, meeting_days=[True] * 7, start_time=time(11, 30),
                    end_time=time(12, 20), meeting_type='LEC', section=self.sections[1]),
            Meeting(id=21, meeting_days=[True] * 7, start_time=time(8),
                    end_time=time(8, 50), meeting_type='LAB', section=self.sections[1]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 502 should be filtered because of the unavailable time
        valid_sections = set((1,))
        meetings_for_sections = {1: meetings[0:2]}
        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #7
0
    def test__get_meetings_filters_asynchronous(self):
        """ Tests that _get_meetings filters asynchronous sections if the
            asynchrnous filter is 'exclude'
        """
        # Arrange
        course = CourseFilter("CSCE",
                              "121",
                              asynchronous=BasicFilter.EXCLUDE,
                              include_full=True)
        term = "201931"
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-501
            Meeting(id=40,
                    meeting_days=[True] * 7,
                    start_time=time(11, 30),
                    end_time=time(12, 20),
                    meeting_type='LEC',
                    section=self.sections[3]),
            Meeting(id=41,
                    meeting_days=[True] * 7,
                    start_time=time(9, 10),
                    end_time=time(10),
                    meeting_type='LAB',
                    section=self.sections[3]),
            # Meetings for CSCE 121-M99
            Meeting(id=70,
                    meeting_days=[False] * 7,
                    start_time=None,
                    end_time=None,
                    meeting_type='LEC',
                    section=self.sections[6]),
            Meeting(id=71,
                    meeting_days=[False] * 7,
                    start_time=None,
                    end_time=None,
                    meeting_type='LAB',
                    section=self.sections[6]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 501 should be filtered because it isn't a remote section
        valid_sections = set((4, ))
        meetings_for_sections = {4: meetings[:2]}

        # Act
        result_meetings = _get_meetings(course, term, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(result_meetings, valid_sections,
                                            meetings_for_sections)
コード例 #8
0
    def test__get_meetings_filters_non_honors(self):
        """ Tests that _get_meetings filters out non-honors sections if the honors
            attribute of the CourseFilter is 'only'
        """
        # Arrange
        course = CourseFilter("CSCE",
                              "121",
                              honors=BasicFilter.ONLY,
                              include_full=True)
        term = "201931"
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-502
            Meeting(id=50,
                    meeting_days=[True] * 7,
                    start_time=time(12, 30),
                    end_time=time(1, 20),
                    meeting_type='LEC',
                    section=self.sections[4]),
            Meeting(id=51,
                    meeting_days=[True] * 7,
                    start_time=time(10),
                    end_time=time(10, 50),
                    meeting_type='LAB',
                    section=self.sections[4]),
            # Meetings for CSCE 121-201
            Meeting(id=60,
                    meeting_days=[True] * 7,
                    start_time=time(12, 30),
                    end_time=time(1, 20),
                    meeting_type='LEC',
                    section=self.sections[5]),
            Meeting(id=61,
                    meeting_days=[True] * 7,
                    start_time=time(10),
                    end_time=time(10, 50),
                    meeting_type='LAB',
                    section=self.sections[5]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section 502 should be filtered because it isn't an honors section
        valid_sections = set((6, ))
        meetings_for_sections = {6: meetings[2:]}

        # Act
        meetings = _get_meetings(course, term, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #9
0
    def test__get_meetings_handles_no_sections(self):
        """ Tests that for a course with no sections, _get_meetings returns
            empty reults
        """
        # Arrange
        course = CourseFilter("CSCE", "123")
        term = "201931"
        include_full = True
        unavailable_times = []

        # Act
        meetings = _get_meetings(course, term, include_full, unavailable_times)

        # Assert
        self.assertFalse(meetings)
コード例 #10
0
    def test__get_meetings_manually_selected_sections_override_include_full(
            self):
        """ Tests that _get_meetings does not filter full sections selected in section
            select when include_full is false
        """
        # Arrange
        # section chosen because it is full
        section_nums = ["502"]
        course = CourseFilter("CSCE",
                              "121",
                              section_nums=section_nums,
                              include_full=False)
        term = "201931"
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-502
            Meeting(id=1,
                    meeting_days=[True] * 7,
                    start_time=time(12, 30),
                    end_time=time(1, 20),
                    meeting_type='LEC',
                    section=self.sections[4]),
            Meeting(id=51,
                    meeting_days=[True] * 7,
                    start_time=time(10),
                    end_time=time(10, 50),
                    meeting_type='LAB',
                    section=self.sections[4]),
        ]
        Meeting.objects.bulk_create(meetings)
        valid_sections = set((5, ))
        meetings_for_sections = {5: meetings[0:]}

        # Act
        meetings = _get_meetings(course, term, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)
コード例 #11
0
    def test__get_meetings_filters_remote(self):
        """ Tests that _get_meetings filters remote sections if the honors attribute
            of the CourseFilter is 'exclude'
        """
        # Arrange
        course = CourseFilter("CSCE",
                              "121",
                              remote=BasicFilter.EXCLUDE,
                              include_full=True)
        term = "201931"
        unavailable_times = []
        meetings = [
            # Meetings for CSCE 121-501
            Meeting(id=40,
                    meeting_days=[True] * 7,
                    start_time=time(11, 30),
                    end_time=time(12, 20),
                    meeting_type='LEC',
                    section=self.sections[3]),
            Meeting(id=41,
                    meeting_days=[True] * 7,
                    start_time=time(9, 10),
                    end_time=time(10),
                    meeting_type='LAB',
                    section=self.sections[3]),
            # Meetings for CSCE 121-502
            Meeting(id=50,
                    meeting_days=[True] * 7,
                    start_time=time(12, 30),
                    end_time=time(1, 20),
                    meeting_type='LEC',
                    section=self.sections[4]),
            Meeting(id=51,
                    meeting_days=[True] * 7,
                    start_time=time(10),
                    end_time=time(10, 50),
                    meeting_type='LAB',
                    section=self.sections[4]),
            # Meetings for CSCE 121-M99
            Meeting(id=70,
                    meeting_days=[False] * 7,
                    start_time=None,
                    end_time=None,
                    meeting_type='LEC',
                    section=self.sections[6]),
            Meeting(id=71,
                    meeting_days=[False] * 7,
                    start_time=None,
                    end_time=None,
                    meeting_type='LAB',
                    section=self.sections[6]),
        ]
        Meeting.objects.bulk_create(meetings)
        # Section M99 should be filtered because it's a remote section
        valid_sections = set((4, 5))
        meetings_for_sections = {4: meetings[0:2], 5: meetings[2:4]}

        # Act
        meetings = _get_meetings(course, term, unavailable_times)

        # Assert
        self.assert_meetings_match_expected(meetings, valid_sections,
                                            meetings_for_sections)