示例#1
0
    def test_final_exams(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = SectionSws.get_section_by_label('2013,summer,B BIO,180/A')
            self.assertEquals(section.final_exam, None, "No final exam for B BIO 180")

            section = SectionSws.get_section_by_label('2013,summer,MATH,125/G')
            final_exam = section.final_exam

            self.assertEquals(final_exam.is_confirmed, False, "Final exam for Math 125 isn't confirmed")
            self.assertEquals(final_exam.no_exam_or_nontraditional, False, "Final exam for Math 125 isn't non-traditional")
            section = SectionSws.get_section_by_label('2013,summer,TRAIN,101/A')
            final_exam = section.final_exam

            self.assertEquals(final_exam.is_confirmed, True, "Final exam for Train 101 is confirmed")
            self.assertEquals(final_exam.no_exam_or_nontraditional, False, "Final exam for Train 101 isn't non-traditional")
            self.assertEquals(final_exam.building, "KNE", "Has right final building")
            self.assertEquals(final_exam.room_number, "012", "Has right room #")

            start = final_exam.start_date
            end = final_exam.end_date

            self.assertEquals(start.year, 2013)
            self.assertEquals(start.month, 6)
            self.assertEquals(start.day, 2)
            self.assertEquals(start.hour, 13)
            self.assertEquals(start.minute, 30)

            self.assertEquals(end.year, 2013)
            self.assertEquals(end.month, 6)
            self.assertEquals(end.day, 2)
            self.assertEquals(end.hour, 16)
            self.assertEquals(end.minute, 20)
示例#2
0
    def test_instructors_in_section(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = SectionSws.get_section_by_label('2013,winter,ASIAN,203/A')

            self.assertEquals(len(section.get_instructors()), 1, "Correct number of instructors")

            person1 = Person(uwregid="FBB38FE46A7C11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_instructor(person1), False, "Person is not instructor")

            person2 = Person(uwregid="6DF0A9206A7D11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_instructor(person2), True, "Person is instructor")

            section2 = SectionSws.get_section_by_label('2013,summer,TRAIN,101/A')
            self.assertEquals(len(section2.get_instructors()), 2, "Correct number of instructors")

            section3 = SectionSws.get_section_by_label('2013,spring,PHYS,121/A')
            self.assertEquals(len(section3.get_instructors()), 5,
                              "Correct number of all instructors")

            section3 = SectionSws.get_section_by_label('2013,spring,PHYS,121/A', False)
            self.assertEquals(len(section3.get_instructors()), 4,
                              "Correct number of TSPrinted instructors")
示例#3
0
    def test_instructors_in_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2013,winter,ASIAN,203/A')

            self.assertEquals(len(section.get_instructors()), 1,
                              "Correct number of instructors")

            person1 = Person(uwregid="FBB38FE46A7C11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_instructor(person1), False,
                              "Person is not instructor")

            person2 = Person(uwregid="6DF0A9206A7D11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_instructor(person2), True,
                              "Person is instructor")

            section2 = get_section_by_label('2013,summer,TRAIN,101/A')
            self.assertEquals(len(section2.get_instructors()), 2,
                              "Correct number of instructors")

            section3 = get_section_by_label('2013,spring,PHYS,121/A')
            self.assertEquals(len(section3.get_instructors()), 5,
                              "Correct number of all instructors")

            section3 = get_section_by_label('2013,spring,PHYS,121/A', False)
            self.assertEquals(len(section3.get_instructors()), 4,
                              "Correct number of TSPrinted instructors")
示例#4
0
    def test_section_by_label(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            #Valid data, shouldn't throw any exceptions
            get_section_by_label('2013,summer,TRAIN,100/A')

            #Invalid data, should throw exceptions
            self.assertRaises(InvalidSectionID, get_section_by_label, '')

            self.assertRaises(InvalidSectionID, get_section_by_label, ' ')

            self.assertRaises(InvalidSectionID, get_section_by_label, '2012')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              '2012,summer')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              '2012,summer,TRAIN')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              '2012, summer, TRAIN, 100')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              'summer, TRAIN, 100/A')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              '2012,fall,TRAIN,100/A')

            self.assertRaises(InvalidSectionID, get_section_by_label,
                              '-2012,summer,TRAIN,100/A')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '9999,summer,TRAIN,100/A')

            #Valid section labels, no files for them
            self.assertRaises(DataFailureException, get_section_by_label,
                              '2012,summer,TRAIN,110/A')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2012,summer,TRAIN,100/B')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2012,summer,PHYS,121/B')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2012,summer,PHYS,121/BB')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2010,autumn,G H,201/A')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2010,autumn,CS&SS,221/A')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2010,autumn,KOREAN,101/A')

            self.assertRaises(DataFailureException, get_section_by_label,
                              '2010,autumn,CM,101/A')
示例#5
0
    def test_instructor_published(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            # Published Instructors
            pi_section = SectionSws.get_section_by_label('2013,summer,B BIO,180/A')
            self.assertEquals(pi_section.meetings[0].instructors[0].TSPrint, True)

            # Unpublished Instructors
            upi_section = SectionSws.get_section_by_label('2013,summer,MATH,125/G')
            self.assertEquals(upi_section.meetings[0].instructors[0].TSPrint, False)
示例#6
0
    def test_joint_sections(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2013,winter,ASIAN,203/A')
            joint_sections = get_joint_sections(section)

            self.assertEquals(len(joint_sections), 1)

            section = get_section_by_label('2013,winter,EMBA,503/A')
            joint_sections = get_joint_sections(section)

            self.assertEquals(len(joint_sections), 0)
示例#7
0
    def test_instructor_published(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            # Published Instructors
            pi_section = get_section_by_label('2013,summer,B BIO,180/A')
            self.assertEquals(pi_section.meetings[0].instructors[0].TSPrint,
                              True)

            # Unpublished Instructors
            upi_section = get_section_by_label('2013,summer,MATH,125/G')
            self.assertEquals(upi_section.meetings[0].instructors[0].TSPrint,
                              False)
示例#8
0
    def test_grading_period_open(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = SectionSws.get_section_by_label('2012,summer,PHYS,121/A')

            self.assertEquals(section.is_grading_period_open(), False, "Grading window is not open")

            # Spring 2013 is 'current' term
            section = SectionSws.get_section_by_label('2013,spring,MATH,125/G')

            self.assertEquals(section.is_grading_period_open(), True, "Grading window is open")
示例#9
0
    def test_grading_period_open(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2012,summer,PHYS,121/A')

            self.assertEquals(section.is_grading_period_open(), False,
                              "Grading window is not open")

            # Spring 2013 is 'current' term
            section = get_section_by_label('2013,spring,MATH,125/G')

            self.assertEquals(section.is_grading_period_open(), True,
                              "Grading window is open")
示例#10
0
    def test_joint_sections(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = SectionSws.get_section_by_label('2013,winter,ASIAN,203/A')
            joint_sections = SectionSws.get_joint_sections(section)

            self.assertEquals(len(joint_sections), 1)

            section = SectionSws.get_section_by_label('2013,winter,EMBA,503/A')
            joint_sections = SectionSws.get_joint_sections(section)

            self.assertEquals(len(joint_sections), 0)
示例#11
0
    def test_secondary_grading(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section1 = get_section_by_label('2012,summer,PHYS,121/A')
            self.assertEquals(section1.allows_secondary_grading, True,
                              "Allows secondary grading")

            for linked in get_linked_sections(section1):
                self.assertEquals(linked.allows_secondary_grading, True,
                                  "Allows secondary grading")

            section2 = get_section_by_label('2013,winter,EMBA,503/A')
            self.assertEquals(section2.allows_secondary_grading, False,
                              "Does not allow secondary grading")
示例#12
0
    def test_all_registrations_with_transcriptable_course(self, mock_get_resource):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,winter,DROP_T,100/B')

            # Test for default resource, i.e. transcriptable_course=yes
            registrations = get_all_registrations_by_section(section)
            mock_get_resource.assert_called_with('/student/v5/registration.json?curriculum_abbreviation=DROP_T&instructor_reg_id=&course_number=100&verbose=true&year=2013&quarter=winter&is_active=&section_id=B')

            # Test for transcriptable_course=yes explicitly
            registrations = get_all_registrations_by_section(
                section, transcriptable_course='yes')
            mock_get_resource.assert_called_with('/student/v5/registration.json?curriculum_abbreviation=DROP_T&instructor_reg_id=&course_number=100&verbose=true&year=2013&quarter=winter&is_active=&section_id=B&transcriptable_course=yes')

            # Test for transcriptable_course=all resource
            registrations = get_all_registrations_by_section(
                section, transcriptable_course='all')
            mock_get_resource.assert_called_with('/student/v5/registration.json?curriculum_abbreviation=DROP_T&instructor_reg_id=&course_number=100&verbose=true&year=2013&quarter=winter&is_active=&section_id=B&transcriptable_course=all')

            # Test for transcriptable_course=no
            registrations = get_all_registrations_by_section(
                section, transcriptable_course='no')
            mock_get_resource.assert_called_with('/student/v5/registration.json?curriculum_abbreviation=DROP_T&instructor_reg_id=&course_number=100&verbose=true&year=2013&quarter=winter&is_active=&section_id=B&transcriptable_course=no')
示例#13
0
    def test_get_graderoster(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]
            requestor = instructor

            graderoster = get_graderoster(section, instructor, requestor)

            self.assertEquals(graderoster.graderoster_label(),
                              "2013,summer,CSS,161,A,%s" % instructor.uwregid,
                              "Correct graderoster_label()")
            self.assertEquals(len(graderoster.grade_submission_delegates), 2, "Grade submission delegates")
            self.assertEquals(len(graderoster.items), 5, "GradeRoster items")

            grades = ['0.7', None, '3.1', '1.5', '4.0']
            labels = ['1914B1B26A7D11D5A4AE0004AC494FFE',
                      '511FC8241DC611DB9943F9D03AACCE31',
                      'F00E253C634211DA9755000629C31437',
                      'C7EED7406A7C11D5A4AE0004AC494FFE',
                      'A9D2DDFA6A7D11D5A4AE0004AC494FFE,A']
            for idx, item in enumerate(graderoster.items):
                self.assertEquals(len(item.grade_choices), 36, "grade_choices returns correct grades")
                self.assertEquals(item.grade, grades[idx], "Correct default grade")
                self.assertEquals(item.student_label(), labels[idx], "Correct student label")
示例#14
0
    def test_get_graderoster(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]

            graderoster = get_graderoster(section, instructor)

            self.assertEquals(graderoster.graderoster_label(),
                              "2013,summer,CSS,161,A,%s" % instructor.uwregid,
                              "Correct graderoster_label()")
            self.assertEquals(len(graderoster.grade_submission_delegates), 2, "Grade submission delegates")
            self.assertEquals(len(graderoster.items), 5, "GradeRoster items")

            grades = ['0.7', None, '3.1', '1.5', '4.0']
            labels = ['1914B1B26A7D11D5A4AE0004AC494FFE',
                      '511FC8241DC611DB9943F9D03AACCE31',
                      'F00E253C634211DA9755000629C31437',
                      'C7EED7406A7C11D5A4AE0004AC494FFE',
                      'A9D2DDFA6A7D11D5A4AE0004AC494FFE,A']
            for idx, item in enumerate(graderoster.items):
                self.assertEquals(len(item.grade_choices), 36, "grade_choices returns correct grades")
                self.assertEquals(item.grade, grades[idx], "Correct default grade")
                self.assertEquals(item.student_label(), labels[idx], "Correct student label")
示例#15
0
    def test_secondary_grading(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):


            section1 = SectionSws.get_section_by_label('2012,summer,PHYS,121/A')
            self.assertEquals(section1.allows_secondary_grading, True,
                              "Allows secondary grading")

            for linked in SectionSws.get_linked_sections(section1):
                self.assertEquals(linked.allows_secondary_grading, True,
                                  "Allows secondary grading")

            section2 = SectionSws.get_section_by_label('2013,winter,EMBA,503/A')
            self.assertEquals(section2.allows_secondary_grading, False,
                              "Does not allow secondary grading")
示例#16
0
    def test_canvas_sis_ids(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            # Primary section containing linked secondary sections
            section = get_section_by_label('2012,summer,PHYS,121/A')
            self.assertEquals(section.canvas_course_sis_id(),
                              '2012-summer-PHYS-121-A', 'Canvas course SIS ID')
            self.assertRaises(InvalidCanvasSection,
                              section.canvas_section_sis_id)

            # Primary section with no linked sections
            section = get_section_by_label('2013,autumn,REHAB,585/A')
            self.assertEquals(section.canvas_course_sis_id(),
                              '2013-autumn-REHAB-585-A',
                              'Canvas course SIS ID')
            self.assertEquals(section.canvas_section_sis_id(),
                              '2013-autumn-REHAB-585-A--',
                              'Canvas section SIS ID')

            # Secondary (linked) section
            section = get_section_by_label('2013,autumn,PHYS,121/AB')
            self.assertEquals(section.canvas_course_sis_id(),
                              '2013-autumn-PHYS-121-A', 'Canvas course SIS ID')
            self.assertEquals(section.canvas_section_sis_id(),
                              '2013-autumn-PHYS-121-AB',
                              'Canvas section SIS ID')

            # Independent study section
            section = get_section_by_label('2013,summer,PHIL,600/A')

            # ..missing instructor regid
            self.assertRaises(InvalidCanvasIndependentStudyCourse,
                              section.canvas_course_sis_id)

            section.independent_study_instructor_regid =\
                'A9D2DDFA6A7D11D5A4AE0004AC494FFE'
            self.assertEquals(
                section.canvas_course_sis_id(),
                '2013-summer-PHIL-600-A-A9D2DDFA6A7D11D5A4AE0004AC494FFE',
                'Canvas course SIS ID')
            self.assertEquals(
                section.canvas_section_sis_id(),
                '2013-summer-PHIL-600-A-A9D2DDFA6A7D11D5A4AE0004AC494FFE--',
                'Canvas section SIS ID')
示例#17
0
def get_section_by_id(section_id):
    label = section_label_from_section_id(section_id)

    section = get_section_by_label(label)

    if section.is_independent_study:
        reg_id = instructor_regid_from_section_id(section_id)
        section.independent_study_instructor_regid = reg_id

    return section
示例#18
0
    def GET(self, request, year, quarter):
        timer = Timer()
        try:
            no_myplan_access = during_myplan_peak_load(
                get_comparison_datetime(request), request)
            if no_myplan_access:
                log_msg(logger, timer,
                        "No MyPlan access during their peak load, abort!")
                return HttpResponse('[]')

            plan = get_plan(regid=get_regid_of_current_user(),
                            year=year,
                            quarter=quarter.lower(),
                            terms=1)
            base_json = plan.json_data()
            has_ready_courses = False
            has_unready_courses = False
            ready_count = 0
            unready_count = 0
            has_sections = False

            for course in base_json["terms"][0]["courses"]:
                if course["registrations_available"]:
                    has_ready_courses = True
                    ready_count = ready_count + 1
                    for section in course["sections"]:
                        has_sections = True
                        curriculum = course["curriculum_abbr"].upper()
                        section_id = section["section_id"].upper()
                        label = "%s,%s,%s,%s/%s" % (year,
                                                    quarter.lower(),
                                                    curriculum,
                                                    course["course_number"],
                                                    section_id
                                                    )

                        sws_section = get_section_by_label(label)
                        section["section_data"] = sws_section.json_data()
                else:
                    if len(course["sections"]):
                        has_sections = True
                    has_unready_courses = True
                    unready_count = unready_count + 1

            base_json["terms"][0]["has_ready_courses"] = has_ready_courses
            base_json["terms"][0]["has_unready_courses"] = has_unready_courses
            base_json["terms"][0]["ready_count"] = ready_count
            base_json["terms"][0]["unready_count"] = unready_count
            base_json["terms"][0]["has_sections"] = has_sections

            log_success_response(logger, timer)
            return HttpResponse(json.dumps(base_json))
        except Exception:
            log_err(logger, timer, traceback.format_exc())
            return HttpResponse('[]')
示例#19
0
    def test_final_exams(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2013,summer,B BIO,180/A')
            self.assertEquals(section.final_exam, None,
                              "No final exam for B BIO 180")

            section = get_section_by_label('2013,summer,MATH,125/G')
            final_exam = section.final_exam

            self.assertEquals(final_exam.is_confirmed, False,
                              "Final exam for Math 125 isn't confirmed")
            self.assertEquals(final_exam.no_exam_or_nontraditional, False,
                              "Final exam for Math 125 isn't non-traditional")
            section = get_section_by_label('2013,summer,TRAIN,101/A')
            final_exam = section.final_exam

            self.assertEquals(final_exam.is_confirmed, True,
                              "Final exam for Train 101 is confirmed")
            self.assertEquals(
                final_exam.no_exam_or_nontraditional, False,
                "Final exam for Train 101 isn't non-traditional")
            self.assertEquals(final_exam.building, "KNE",
                              "Has right final building")
            self.assertEquals(final_exam.room_number, "012",
                              "Has right room #")

            start = final_exam.start_date
            end = final_exam.end_date

            self.assertEquals(start.year, 2013)
            self.assertEquals(start.month, 6)
            self.assertEquals(start.day, 2)
            self.assertEquals(start.hour, 13)
            self.assertEquals(start.minute, 30)

            self.assertEquals(end.year, 2013)
            self.assertEquals(end.month, 6)
            self.assertEquals(end.day, 2)
            self.assertEquals(end.hour, 16)
            self.assertEquals(end.minute, 20)
示例#20
0
    def test_all_registrations_by_section(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            # Valid section, missing file resources
            section = get_section_by_label('2013,winter,C LIT,396/A')

            self.assertRaises(DataFailureException,
                              get_all_registrations_by_section,
                              section)
示例#21
0
    def test_all_registrations_by_section(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            # Valid section, missing file resources
            section = get_section_by_label('2013,winter,C LIT,396/A')

            self.assertRaises(DataFailureException,
                              get_all_registrations_by_section,
                              section)
示例#22
0
    def test_participants_for_section(self):
        with self.settings(
                RESTCLIENTS_CATALYST_DAO_CLASS='restclients.dao_implementation.catalyst.File',
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = sws_section.get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]

            participants = get_participants_for_section(section, instructor)

            self.assertEquals(len(participants), 3, "Correct participant count")
示例#23
0
    def test_active_registration_status_after_drop_and_add(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,winter,DROP_T,100/B')
            registrations = get_all_registrations_by_section(section)

            self.assertEquals(len(registrations), 1)
            javerage_reg = registrations[0]
            self.assertEquals(javerage_reg.person.uwnetid, 'javerage')
            self.assertEquals(javerage_reg.is_active, True)
示例#24
0
    def test_canvas_sis_ids(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            # Primary section containing linked secondary sections
            section = SectionSws.get_section_by_label('2012,summer,PHYS,121/A')
            self.assertEquals(section.canvas_course_sis_id(),
                '2012-summer-PHYS-121-A', 'Canvas course SIS ID')
            self.assertRaises(InvalidCanvasSection,
                              section.canvas_section_sis_id)

            # Primary section with no linked sections
            section = SectionSws.get_section_by_label('2013,autumn,REHAB,585/A')
            self.assertEquals(section.canvas_course_sis_id(),
                '2013-autumn-REHAB-585-A', 'Canvas course SIS ID')
            self.assertEquals(section.canvas_section_sis_id(),
                '2013-autumn-REHAB-585-A--', 'Canvas section SIS ID')

            # Secondary (linked) section
            section = SectionSws.get_section_by_label('2013,autumn,PHYS,121/AB')
            self.assertEquals(section.canvas_course_sis_id(),
                '2013-autumn-PHYS-121-A', 'Canvas course SIS ID')
            self.assertEquals(section.canvas_section_sis_id(),
                '2013-autumn-PHYS-121-AB', 'Canvas section SIS ID')

            # Independent study section
            section = SectionSws.get_section_by_label('2013,summer,PHIL,600/A')

            # ..missing instructor regid
            self.assertRaises(InvalidCanvasIndependentStudyCourse,
                              section.canvas_course_sis_id)

            section.independent_study_instructor_regid = 'A9D2DDFA6A7D11D5A4AE0004AC494FFE'
            self.assertEquals(section.canvas_course_sis_id(),
                '2013-summer-PHIL-600-A-A9D2DDFA6A7D11D5A4AE0004AC494FFE',
                'Canvas course SIS ID')
            self.assertEquals(section.canvas_section_sis_id(),
                '2013-summer-PHIL-600-A-A9D2DDFA6A7D11D5A4AE0004AC494FFE--',
                'Canvas section SIS ID')
示例#25
0
    def test_summer_terms(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2013,summer,B BIO,180/A')
            self.assertFalse(section.is_summer_a_term())
            self.assertFalse(section.is_summer_b_term())
            self.assertFalse(section.is_half_summer_term())
            self.assertTrue(section.is_full_summer_term())

            self.assertTrue(section.is_same_summer_term("full-term"))
            self.assertFalse(section.is_same_summer_term("a-term"))
            self.assertFalse(section.is_same_summer_term("B-term"))
            self.assertFalse(section.is_same_summer_term(None))

            section = get_section_by_label('2013,summer,PHIL,600/A')
            # section.summer_term is ""
            self.assertFalse(section.is_summer_a_term())
            self.assertFalse(section.is_summer_b_term())
            self.assertFalse(section.is_full_summer_term())
            self.assertTrue(section.is_same_summer_term(None))
            self.assertTrue(section.is_same_summer_term(""))
示例#26
0
    def GET(self, request, year, quarter):
        timer = Timer()
        try:
            no_myplan_access = during_myplan_peak_load(
                get_comparison_datetime(request), request)
            if no_myplan_access:
                log_msg(logger, timer,
                        "No MyPlan access during their peak load, abort!")
                return HttpResponse('[]')

            plan = get_plan(regid=get_regid_of_current_user(),
                            year=year,
                            quarter=quarter.lower(),
                            terms=1)
            base_json = plan.json_data()
            has_ready_courses = False
            has_unready_courses = False
            ready_count = 0
            unready_count = 0
            has_sections = False

            for course in base_json["terms"][0]["courses"]:
                if course["registrations_available"]:
                    has_ready_courses = True
                    ready_count = ready_count + 1
                    for section in course["sections"]:
                        has_sections = True
                        curriculum = course["curriculum_abbr"].upper()
                        section_id = section["section_id"].upper()
                        label = "%s,%s,%s,%s/%s" % (year, quarter.lower(
                        ), curriculum, course["course_number"], section_id)

                        sws_section = get_section_by_label(label)
                        section["section_data"] = sws_section.json_data()
                else:
                    if len(course["sections"]):
                        has_sections = True
                    has_unready_courses = True
                    unready_count = unready_count + 1

            base_json["terms"][0]["has_ready_courses"] = has_ready_courses
            base_json["terms"][0]["has_unready_courses"] = has_unready_courses
            base_json["terms"][0]["ready_count"] = ready_count
            base_json["terms"][0]["unready_count"] = unready_count
            base_json["terms"][0]["has_sections"] = has_sections

            log_success_response(logger, timer)
            return HttpResponse(json.dumps(base_json))
        except Exception:
            log_err(logger, timer, traceback.format_exc())
            return HttpResponse('[]')
示例#27
0
    def test_participants_for_section(self):
        with self.settings(RESTCLIENTS_CATALYST_DAO_CLASS=
                           'restclients.dao_implementation.catalyst.File',
                           RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS=
                           'restclients.dao_implementation.pws.File'):

            section = sws_section.get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]

            participants = get_participants_for_section(section, instructor)

            self.assertEquals(len(participants), 3,
                              "Correct participant count")
示例#28
0
    def test_delegates_in_section(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = SectionSws.get_section_by_label('2013,winter,ASIAN,203/A')

            self.assertEquals(len(section.grade_submission_delegates), 3,
                "Correct number of delegates")

            person1 = Person(uwregid="6DF0A9206A7D11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_grade_submission_delegate(person1), False, "Person is not delegate")

            person2 = Person(uwregid="FBB38FE46A7C11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_grade_submission_delegate(person2), True, "Person is delegate")
示例#29
0
    def test_delegates_in_section(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            section = get_section_by_label('2013,winter,ASIAN,203/A')

            self.assertEquals(len(section.grade_submission_delegates), 3,
                              "Correct number of delegates")

            person1 = Person(uwregid="6DF0A9206A7D11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_grade_submission_delegate(person1),
                              False, "Person is not delegate")

            person2 = Person(uwregid="FBB38FE46A7C11D5A4AE0004AC494FFE")
            self.assertEquals(section.is_grade_submission_delegate(person2),
                              True, "Person is delegate")
示例#30
0
    def test_active_registration_status_after_drop_and_add(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,winter,DROP_T,100/B')
            registrations = get_all_registrations_by_section(section)

            self.assertEquals(len(registrations), 3)
            javerage_reg = registrations[2]
            self.assertEquals(javerage_reg.person.uwnetid, 'javerage')
            self.assertEquals(javerage_reg.is_active, True)
            self.assertEquals(javerage_reg.is_auditor, True)
            self.assertEquals(javerage_reg.is_credit, True)
            self.assertEquals(str(javerage_reg.request_date.date()), '2015-11-18')
            self.assertEquals(javerage_reg.request_status, 'ADDED TO CLASS')
            self.assertEquals(javerage_reg.duplicate_code, 'A')
            self.assertEquals(javerage_reg.repository_timestamp.isoformat(), '2016-01-05T02:45:15')
示例#31
0
    def test_put_graderoster(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]

            graderoster = get_graderoster(section, instructor)

            for item in graderoster.items:
                new_grade = str(round(random.uniform(1, 4), 1))
                item.grade = new_grade

            orig_xhtml = split_xhtml(graderoster.xhtml())

            new_graderoster = update_graderoster(graderoster)
            new_xhtml = split_xhtml(new_graderoster.xhtml())
            self.assertEquals(orig_xhtml, new_xhtml, "XHTML is equal")
示例#32
0
    def test_put_graderoster(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            section = get_section_by_label('2013,summer,CSS,161/A')
            instructor = section.meetings[0].instructors[0]
            requestor = instructor

            graderoster = get_graderoster(section, instructor, requestor)

            for item in graderoster.items:
                new_grade = str(round(random.uniform(1, 4), 1))
                item.grade = new_grade

            orig_xhtml = split_xhtml(graderoster.xhtml())

            new_graderoster = update_graderoster(graderoster, requestor)
            new_xhtml = split_xhtml(new_graderoster.xhtml())
            self.assertEquals(orig_xhtml, new_xhtml, "XHTML is equal")
示例#33
0
    def test_linked_sections(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            #Valid data, shouldn't throw any exceptions
            section = SectionSws.get_section_by_label('2013,summer,TRAIN,100/A')
            SectionSws.get_linked_sections(section)

            #Invalid data, should throw exceptions
            section.linked_section_urls = ['']
            self.assertRaises(InvalidSectionURL,
                              SectionSws.get_linked_sections, section)

            section.linked_section_urls = [' ']
            self.assertRaises(InvalidSectionURL,
                              SectionSws.get_linked_sections, section)

            section.linked_section_urls = ['2012,summer,TRAIN,100/A']
            self.assertRaises(InvalidSectionURL,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2012,summer,PHYS,121/B.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2012,summer,PHYS,121/B.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2010,autumn,CS&SS,221/A.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2010,autumn,CS&SS,221/A.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2010,autumn,KOREAN,101/A.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2010,autumn,KOREAN,101/A.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2010,autumn,G H,201/A.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2010,autumn,G H,201/A.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2010,autumn,CM,101/A.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2010,autumn,CM,101/A.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2012,autumn,PHYS,121/A.json',
                                           '/student/v5/course/2012,autumn,PHYS,121/AC.json',
                                           '/student/v5/course/2012,autumn,PHYS,121/BT.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2012,autumn,PHYS,121/A.json',
                                           '/student/v4/course/2012,autumn,PHYS,121/AC.json',
                                           '/student/v4/course/2012,autumn,PHYS,121/BT.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls = ['/student/v5/course/2012,autumn,PHYS,121/A.json',
                                           '/student/v5/course/2012,autumn,PHYS,121/AC.json',
                                           '/student/v5/course/2012,autumn,PHYS,121/AAA.json']
            else:
                section.linked_section_urls = ['/student/v4/course/2012,autumn,PHYS,121/A.json',
                                           '/student/v4/course/2012,autumn,PHYS,121/AC.json',
                                           '/student/v4/course/2012,autumn,PHYS,121/AAA.json']
            self.assertRaises(DataFailureException,
                              SectionSws.get_linked_sections, section)
    def _process_course(self, session_id):
        # 2015-spring-PSYCH-202-A-2015-06-04
        course = re.match(
            r'^(20[0-9]{2})-(winter|spring|summer|autumn)'
            r'-([A-Z ]+)-([0-9]{3})-([A-Z][A-Z0-9]*)-2*', session_id)

        if course:
            label = "%s,%s,%s,%s/%s" % (course.group(1), course.group(2),
                                        course.group(3), course.group(4),
                                        course.group(5))

            if label not in self._courses:
                now = datetime.datetime.now(tz.tzlocal()).replace(
                    second=0, microsecond=0)
                section = get_section_by_label(
                    label, include_instructor_not_on_time_schedule=False)
                (start, end) = self._lecture_times(section)
                self._courses[label] = {
                    'start': start.split(':'),
                    'end': end.split(':')
                }

            offered = self._courses[label]
        else:
            print >> sys.stderr, "unrecognized session id: %s" % session_id
            return

        pan_session = self._session.getSessionsByExternalId([session_id])
        if 'Session' in pan_session and len(pan_session.Session) == 1:
            # broken-ass suds.
            fsuds = re.match(r'.*\<a\:StartTime\>([^<]+)\<\/a\:StartTime\>.*',
                             self._session._api.last_received().plain())
            if not fsuds:
                Exception('Untrustable time')

            pan_start = parser.parse(fsuds.group(1))
            pan_start_local = pan_start.astimezone(tz.tzlocal())
            sws_start_local = pan_start_local.replace(
                hour=int(offered['start'][0]), minute=int(offered['start'][1]))
            sws_end_local = pan_start_local.replace(
                hour=int(offered['end'][0]), minute=int(offered['end'][1]))

            schedule_delta = sws_start_local - pan_start_local

            duration_delta = (sws_end_local - sws_start_local).seconds - int(
                pan_session.Session[0].Duration)

            if schedule_delta or duration_delta:
                pan_start = (pan_start_local + schedule_delta).astimezone(
                    tz.tzutc())

                duration = pan_session.Session[0].Duration
                if duration_delta:
                    duration += duration_delta

                pan_end = pan_start + datetime.timedelta(0, duration)

                adjustment = [
                    session_id,
                    '(%s)' % pan_session.Session[0].Id,
                    '' if self._commit else 'WOULD', 'RESCHEDULE',
                    fsuds.group(1), 'TO',
                    pan_start.isoformat(), ':'
                ]

                if schedule_delta.days < 0:
                    adjustment.append("(-%s shift)" %
                                      (datetime.timedelta() - schedule_delta))
                else:
                    adjustment.append("(%s shift)" % schedule_delta)

                if duration_delta:
                    adjustment.append('AND DURATION')
                    adjustment.append("%s" % duration_delta)
                    adjustment.append('seconds')

                print >> sys.stderr, ' '.join(adjustment)

                if self._commit:
                    result = self._recorder.updateRecordingTime(
                        pan_session.Session[0].Id, pan_start.isoformat(),
                        pan_end.isoformat())
                    if not result:
                        print >> sys.stderr, "FAIL: null return value"
                    elif result.ConflictsExist:
                        print >> sys.stderr, "CONFLICT: %s" % (
                            result.ConflictingSessions[0][0].SessionName)
                    else:
                        print >> sys.stderr, "UPDATED %s" % (
                            result.SessionIDs[0][0])
            else:
                print >> sys.stderr, "%s: UNCHANGED" % (session_id)

        else:
            print >> sys.stderr, "unrecognized session id: %s" % session_id
    def _process_course(self, session_id):
        # 2015-spring-PSYCH-202-A-2015-06-04
        course = re.match(r'^(20[0-9]{2})-(winter|spring|summer|autumn)'
                          r'-([A-Z ]+)-([0-9]{3})-([A-Z][A-Z0-9]*)-2*',
                          session_id)

        if course:
            label = "%s,%s,%s,%s/%s" % (
                course.group(1), course.group(2), course.group(3),
                course.group(4), course.group(5))

            if label not in self._courses:
                now = datetime.datetime.now(
                    tz.tzlocal()).replace(second=0, microsecond=0)
                section = get_section_by_label(
                    label, include_instructor_not_on_time_schedule=False)
                (start, end) = self._lecture_times(section)
                self._courses[label] = {
                    'start': start.split(':'),
                    'end': end.split(':')
                }

            offered = self._courses[label]
        else:
            print >> sys.stderr, "unrecognized session id: %s" % session_id
            return

        pan_session = self._session.getSessionsByExternalId([session_id])
        if 'Session' in pan_session and len(pan_session.Session) == 1:
            # broken-ass suds.
            fsuds = re.match(r'.*\<a\:StartTime\>([^<]+)\<\/a\:StartTime\>.*',
                             self._session._api.last_received().plain())
            if not fsuds:
                Exception('Untrustable time')

            pan_start = parser.parse(fsuds.group(1))
            pan_start_local = pan_start.astimezone(tz.tzlocal())
            sws_start_local = pan_start_local.replace(
                hour=int(offered['start'][0]),
                minute=int(offered['start'][1]))
            sws_end_local = pan_start_local.replace(
                hour=int(offered['end'][0]),
                minute=int(offered['end'][1]))

            schedule_delta = sws_start_local - pan_start_local

            duration_delta = (sws_end_local - sws_start_local).seconds - int(
                pan_session.Session[0].Duration)

            if schedule_delta or duration_delta:
                pan_start = (pan_start_local +
                             schedule_delta).astimezone(tz.tzutc())

                duration = pan_session.Session[0].Duration
                if duration_delta:
                    duration += duration_delta

                pan_end = pan_start + datetime.timedelta(0, duration)

                adjustment = [session_id, '(%s)' % pan_session.Session[0].Id,
                              '' if self._commit else 'WOULD', 'RESCHEDULE',
                              fsuds.group(1), 'TO',
                              pan_start.isoformat(), ':']

                if schedule_delta.days < 0:
                    adjustment.append("(-%s shift)" % (datetime.timedelta() -
                                                       schedule_delta))
                else:
                    adjustment.append("(%s shift)" % schedule_delta)

                if duration_delta:
                    adjustment.append('AND DURATION')
                    adjustment.append("%s" % duration_delta)
                    adjustment.append('seconds')

                print >> sys.stderr, ' '.join(adjustment)

                if self._commit:
                    result = self._recorder.updateRecordingTime(
                        pan_session.Session[0].Id,
                        pan_start.isoformat(),
                        pan_end.isoformat())
                    if not result:
                        print >> sys.stderr, "FAIL: null return value"
                    elif result.ConflictsExist:
                        print >> sys.stderr, "CONFLICT: %s" % (
                            result.ConflictingSessions[0][0].SessionName)
                    else:
                        print >> sys.stderr, "UPDATED %s" % (
                            result.SessionIDs[0][0])
            else:
                print >> sys.stderr, "%s: UNCHANGED" % (session_id)

        else:
            print >> sys.stderr, "unrecognized session id: %s" % session_id
示例#36
0
    def test_section_by_label(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            #Valid data, shouldn't throw any exceptions
            SectionSws.get_section_by_label('2013,summer,TRAIN,100/A')

            #Invalid data, should throw exceptions
            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              ' ')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '2012')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '2012,summer')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '2012,summer,TRAIN')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '2012, summer, TRAIN, 100')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              'summer, TRAIN, 100/A')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '2012,fall,TRAIN,100/A')

            self.assertRaises(InvalidSectionID,
                              SectionSws.get_section_by_label,
                              '-2012,summer,TRAIN,100/A')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '9999,summer,TRAIN,100/A')

            #Valid section labels, no files for them
            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2012,summer,TRAIN,110/A')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2012,summer,TRAIN,100/B')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2012,summer,PHYS,121/B')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2012,summer,PHYS,121/BB')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2010,autumn,G H,201/A')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2010,autumn,CS&SS,221/A')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2010,autumn,KOREAN,101/A')

            self.assertRaises(DataFailureException,
                              SectionSws.get_section_by_label,
                              '2010,autumn,CM,101/A')
示例#37
0
 def get_section_by_label(self, label,
                          include_instructor_not_on_time_schedule=True):
     deprecation("Use restclients.sws.section.get_section_by_label")
     from restclients.sws.section import get_section_by_label
     return get_section_by_label(label, include_instructor_not_on_time_schedule)
def get_sws_section(course):
    return get_section_by_label(sws_course_id(course),
                                include_instructor_not_on_time_schedule=False)
示例#39
0
def get_sws_section(course):
    return get_section_by_label(sws_course_id(course),
                                include_instructor_not_on_time_schedule=False)
示例#40
0
    def test_linked_sections(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            #Valid data, shouldn't throw any exceptions
            section = get_section_by_label('2013,summer,TRAIN,100/A')
            get_linked_sections(section)

            #Invalid data, should throw exceptions
            section.linked_section_urls = ['']
            self.assertRaises(InvalidSectionURL, get_linked_sections, section)

            section.linked_section_urls = [' ']
            self.assertRaises(InvalidSectionURL, get_linked_sections, section)

            section.linked_section_urls = ['2012,summer,TRAIN,100/A']
            self.assertRaises(InvalidSectionURL, get_linked_sections, section)

            if use_v5_resources():
                section.linked_section_urls =\
                    ['/student/v5/course/2012,summer,PHYS,121/B.json']
            else:
                section.linked_section_urls =\
                    ['/student/v4/course/2012,summer,PHYS,121/B.json']
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls =\
                ['/student/v5/course/2010,autumn,CS&SS,221/A.json']
            else:
                section.linked_section_urls =\
                    ['/student/v4/course/2010,autumn,CS&SS,221/A.json']
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls =\
                    ['/student/v5/course/2010,autumn,KOREAN,101/A.json']
            else:
                section.linked_section_urls =\
                    ['/student/v4/course/2010,autumn,KOREAN,101/A.json']
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls =\
                ['/student/v5/course/2010,autumn,G H,201/A.json']
            else:
                section.linked_section_urls =\
                    ['/student/v4/course/2010,autumn,G H,201/A.json']
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls =\
                    ['/student/v5/course/2010,autumn,CM,101/A.json']
            else:
                section.linked_section_urls =\
                    ['/student/v4/course/2010,autumn,CM,101/A.json']
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls = [
                    '/student/v5/course/2012,autumn,PHYS,121/A.json',
                    '/student/v5/course/2012,autumn,PHYS,121/AC.json',
                    '/student/v5/course/2012,autumn,PHYS,121/BT.json'
                ]
            else:
                section.linked_section_urls = [
                    '/student/v4/course/2012,autumn,PHYS,121/A.json',
                    '/student/v4/course/2012,autumn,PHYS,121/AC.json',
                    '/student/v4/course/2012,autumn,PHYS,121/BT.json'
                ]
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)

            if use_v5_resources():
                section.linked_section_urls = [
                    '/student/v5/course/2012,autumn,PHYS,121/A.json',
                    '/student/v5/course/2012,autumn,PHYS,121/AC.json',
                    '/student/v5/course/2012,autumn,PHYS,121/AAA.json'
                ]
            else:
                section.linked_section_urls = [
                    '/student/v4/course/2012,autumn,PHYS,121/A.json',
                    '/student/v4/course/2012,autumn,PHYS,121/AC.json',
                    '/student/v4/course/2012,autumn,PHYS,121/AAA.json'
                ]
            self.assertRaises(DataFailureException, get_linked_sections,
                              section)
示例#41
0
 def get_section_by_label(self, label,
                          include_instructor_not_on_time_schedule=True):
     deprecation("Use restclients.sws.section.get_section_by_label")
     from restclients.sws.section import get_section_by_label
     return get_section_by_label(label, include_instructor_not_on_time_schedule)