예제 #1
0
    def test_quarter_after(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
예제 #2
0
    def test_term_before(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next1 = get_term_before(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'spring')

            next2 = get_term_before(next1)
            self.assertEquals(next2.year, 2013)
            self.assertEquals(next2.quarter, 'winter')

            next3 = get_term_before(next2)
            self.assertEquals(next3.year, 2012)
            self.assertEquals(next3.quarter, 'autumn')
예제 #3
0
    def test_term_before(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next1 = get_term_before(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'spring')

            next2 = get_term_before(next1)
            self.assertEquals(next2.year, 2013)
            self.assertEquals(next2.quarter, 'winter')

            next3 = get_term_before(next2)
            self.assertEquals(next3.year, 2012)
            self.assertEquals(next3.quarter, 'autumn')
예제 #4
0
    def test_terms_after(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next_autumn = get_next_autumn_term(starting)
            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            self.assertEquals(next_autumn, next1)
            next_non_summer_term = get_next_non_summer_term(get_current_term())
            self.assertEquals(next_autumn, next_non_summer_term)

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
예제 #5
0
    def test_terms_after(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            starting = get_next_term()
            self.assertEquals(starting.year, 2013)
            self.assertEquals(starting.quarter, 'summer')

            next_autumn = get_next_autumn_term(starting)
            next1 = get_term_after(starting)
            self.assertEquals(next1.year, 2013)
            self.assertEquals(next1.quarter, 'autumn')

            self.assertEquals(next_autumn, next1)
            next_non_summer_term = get_next_non_summer_term(get_current_term())
            self.assertEquals(next_autumn, next_non_summer_term)

            next2 = get_term_after(next1)
            self.assertEquals(next2.year, 2014)
            self.assertEquals(next2.quarter, 'winter')
예제 #6
0
    def test_next_quarter(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            term = get_next_term()

            expected_quarter = "summer"
            expected_year = 2013

            self.assertEquals(term.year, expected_year,
                              "Return %s for the next year" %
                              expected_year)

            self.assertEquals(term.quarter, expected_quarter,
                              "Return %s for the next quarter" %
                              expected_quarter)

            self.assertEquals(term.last_day_add.year, 2013)
            self.assertEquals(term.last_day_add.month, 7)
            self.assertEquals(term.last_day_add.day, 14)

            self.assertEquals(term.last_day_drop.year, 2013)
            self.assertEquals(term.last_day_drop.month, 8)
            self.assertEquals(term.last_day_drop.day, 11)

            self.assertEquals(term.first_day_quarter.year, 2013)
            self.assertEquals(term.first_day_quarter.month, 6)
            self.assertEquals(term.first_day_quarter.day, 24)

            self.assertEquals(term.last_day_instruction.year, 2013)
            self.assertEquals(term.last_day_instruction.month, 8)
            self.assertEquals(term.last_day_instruction.day, 23)

            self.assertEquals(term.aterm_last_date.year, 2013)
            self.assertEquals(term.aterm_last_date.month, 7)
            self.assertEquals(term.aterm_last_date.day, 24)

            self.assertEquals(term.bterm_first_date.year, 2013)
            self.assertEquals(term.bterm_first_date.month, 7)
            self.assertEquals(term.bterm_first_date.day, 25)

            self.assertEquals(term.aterm_last_day_add.year, 2013)
            self.assertEquals(term.aterm_last_day_add.month, 7)
            self.assertEquals(term.aterm_last_day_add.day, 14)

            self.assertEquals(term.bterm_last_day_add.year, 2013)
            self.assertEquals(term.bterm_last_day_add.month, 7)
            self.assertEquals(term.bterm_last_day_add.day, 31)

            self.assertEquals(term.last_final_exam_date.year, 2013)
            self.assertEquals(term.last_final_exam_date.month, 8)
            self.assertEquals(term.last_final_exam_date.day, 23)

            self.assertEquals(term.grade_submission_deadline.date().year, 2013)
            self.assertEquals(term.grade_submission_deadline.date().month, 8)
            self.assertEquals(term.grade_submission_deadline.date().day, 27)
            self.assertEquals(term.grade_submission_deadline.time().hour, 17)
            self.assertEquals(term.grade_submission_deadline.time().minute, 0)

            self.assertEquals(term.aterm_grading_period_open.date().year, 2013)
            self.assertEquals(term.aterm_grading_period_open.date().month, 7)
            self.assertEquals(term.aterm_grading_period_open.date().day, 18)
            self.assertEquals(term.aterm_grading_period_open.time().hour, 8)
            self.assertEquals(term.aterm_grading_period_open.time().minute, 0)

            self.assertEquals(len(term.time_schedule_construction), 3)

            for tsc in term.time_schedule_construction:
                if tsc.campus == 'bothell':
                    self.assertEquals(tsc.is_on, True)

            self.assertEquals(term.is_grading_period_open(), False, "Grading period is not open")
            self.assertEquals(term.is_grading_period_past(), True, "Grading period is past")
            self.assertEquals(term.term_label(), "2013,summer", "Term label")
예제 #7
0
def space_events_and_recordings(params):
    search = {
        'space_id': params.get('space_id'),
        'start_dt': params.get('start_dt'),
        'session_ids': params.get('session_ids'),
    }

    current_term = get_current_term()
    next_term = get_next_term()

    event_sessions = []
    event_external_ids = []
    recorders = {search['space_id']: params.get('recorder_id')}

    if search['session_ids']:
        sessions = get_sessions_by_session_ids(
            search['session_ids'].split(','))

        for s in sessions:
            event_session = event_session_from_scheduled_recording(s)
            event_sessions.append(event_session)

        return event_sessions

    if search['space_id'] and search['start_dt']:
        start_dt = parser.parse(search['start_dt']).date()

        reservations = get_reservations(**search)

        # build event sessions, accounting for joint class reservations
        for r in reservations:
            event_session = event_session_from_reservation(r)

            for s in event_sessions:
                if event_session['recording']['start'] == s['recording'][
                        'start']:
                    if isinstance(s['name'], list):
                        s['name'].append(event_session['name'])
                        s['name'].sort()
                    else:
                        s['name'] = [s['name'], event_session['name']]

                    event_session = None
                    break

            if event_session:
                event_sessions.append(event_session)

        # overlay session data
        for event_session in list(event_sessions):
            # remove academic courses and generate external_id
            if event_session['profile'].lower() in UW_MEETING_TYPES:
                event_sessions.remove(event_session)
            else:
                set_panopto_generic_folder(event_session)
                set_panopto_generic_session(event_session)
                event_external_ids.append(
                    event_session['recording']['external_id'])

    mash_in_panopto_sessions(event_sessions, event_external_ids, recorders)

    return event_sessions
def space_events_and_recordings(params):
    search = {
        'space_id': params.get('space_id'),
        'start_dt': params.get('start_dt'),
        'session_ids': params.get('session_ids'),
    }

    current_term = get_current_term()
    next_term = get_next_term()

    event_sessions = []
    event_external_ids = []
    recorders = {
        search['space_id']: params.get('recorder_id')
    }

    if search['session_ids']:
        sessions = get_sessions_by_session_ids(
            search['session_ids'].split(','))

        for s in sessions:
            event_session = event_session_from_scheduled_recording(s)
            event_sessions.append(event_session)

        return event_sessions

    if search['space_id'] and search['start_dt']:
        start_dt = parser.parse(search['start_dt']).date()

        reservations = get_reservations(**search)

        # build event sessions, accounting for joint class reservations
        for r in reservations:
            event_session = event_session_from_reservation(r)

            for s in event_sessions:
                if event_session['recording'][
                        'start'] == s['recording']['start']:
                    if isinstance(s['name'], list):
                        s['name'].append(event_session['name'])
                        s['name'].sort()
                    else:
                        s['name'] = [s['name'], event_session['name']]

                    event_session = None
                    break

            if event_session:
                event_sessions.append(event_session)

        # overlay session data
        for event_session in list(event_sessions):
            # remove academic courses and generate external_id
            if event_session['profile'].lower() in UW_MEETING_TYPES:
                event_sessions.remove(event_session)
            else:
                set_panopto_generic_folder(event_session)
                set_panopto_generic_session(event_session)
                event_external_ids.append(event_session['recording']['external_id'])

    mash_in_panopto_sessions(event_sessions, event_external_ids, recorders)

    return event_sessions
예제 #9
0
    def test_next_quarter(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            term = get_next_term()
            self.assertTrue(term.is_summer_quarter())
            expected_quarter = "summer"
            expected_year = 2013

            self.assertEquals(term.year, expected_year,
                              "Return %s for the next year" %
                              expected_year)

            self.assertEquals(term.quarter, expected_quarter,
                              "Return %s for the next quarter" %
                              expected_quarter)

            self.assertEquals(term.census_day.year, 2013)
            self.assertEquals(term.census_day.month, 7)
            self.assertEquals(term.census_day.day, 5)
            self.assertEquals(term.get_eod_census_day(),
                              datetime(2013, 7, 6, 0, 0, 0))

            self.assertEquals(term.last_day_add.year, 2013)
            self.assertEquals(term.last_day_add.month, 7)
            self.assertEquals(term.last_day_add.day, 14)
            self.assertEquals(term.get_eod_last_day_add(),
                              datetime(2013, 7, 15, 0, 0, 0))

            self.assertEquals(term.last_day_drop.year, 2013)
            self.assertEquals(term.last_day_drop.month, 8)
            self.assertEquals(term.last_day_drop.day, 11)
            self.assertEquals(term.get_eod_last_day_drop(),
                              datetime(2013, 8, 12, 0, 0, 0))

            self.assertEquals(term.first_day_quarter.year, 2013)
            self.assertEquals(term.first_day_quarter.month, 6)
            self.assertEquals(term.first_day_quarter.day, 24)
            self.assertEquals(term.get_bod_first_day(),
                              datetime(2013, 6, 24, 0, 0, 0))

            self.assertEquals(term.last_day_instruction.year, 2013)
            self.assertEquals(term.last_day_instruction.month, 8)
            self.assertEquals(term.last_day_instruction.day, 23)
            self.assertEquals(term.get_eod_last_instruction(),
                              datetime(2013, 8, 24, 0, 0, 0))

            self.assertEquals(term.aterm_last_date.year, 2013)
            self.assertEquals(term.aterm_last_date.month, 7)
            self.assertEquals(term.aterm_last_date.day, 24)

            self.assertEquals(term.bterm_first_date.year, 2013)
            self.assertEquals(term.bterm_first_date.month, 7)
            self.assertEquals(term.bterm_first_date.day, 25)
            self.assertEquals(term.get_eod_summer_aterm(),
                              datetime(2013, 7, 25, 0, 0, 0))

            self.assertEquals(term.aterm_last_day_add.year, 2013)
            self.assertEquals(term.aterm_last_day_add.month, 7)
            self.assertEquals(term.aterm_last_day_add.day, 14)
            self.assertEquals(term.get_eod_aterm_last_day_add(),
                              datetime(2013, 7, 15, 0, 0, 0))

            self.assertEquals(term.bterm_last_day_add.year, 2013)
            self.assertEquals(term.bterm_last_day_add.month, 7)
            self.assertEquals(term.bterm_last_day_add.day, 31)
            self.assertEquals(term.get_eod_bterm_last_day_add(),
                              datetime(2013, 8, 1, 0, 0, 0))

            self.assertEquals(term.last_final_exam_date.year, 2013)
            self.assertEquals(term.last_final_exam_date.month, 8)
            self.assertEquals(term.last_final_exam_date.day, 23)
            self.assertEquals(term.get_eod_last_final_exam(),
                              datetime(2013, 8, 24, 0, 0, 0))

            self.assertEquals(term.grade_submission_deadline.date().year, 2013)
            self.assertEquals(term.grade_submission_deadline.date().month, 8)
            self.assertEquals(term.grade_submission_deadline.date().day, 27)
            self.assertEquals(term.grade_submission_deadline.time().hour, 17)
            self.assertEquals(term.grade_submission_deadline.time().minute, 0)
            self.assertEquals(term.get_eod_grade_submission(),
                              datetime(2013, 8, 28, 0, 0, 0))

            self.assertEquals(term.aterm_grading_period_open.date().year, 2013)
            self.assertEquals(term.aterm_grading_period_open.date().month, 7)
            self.assertEquals(term.aterm_grading_period_open.date().day, 18)
            self.assertEquals(term.aterm_grading_period_open.time().hour, 8)
            self.assertEquals(term.aterm_grading_period_open.time().minute, 0)

            self.assertEquals(len(term.time_schedule_construction), 3)
            self.assertEquals(term.time_schedule_construction['bothell'], True)

            self.assertEquals(len(term.time_schedule_published), 3)
            self.assertEquals(term.time_schedule_published['bothell'], False)

            self.assertEquals(term.is_grading_period_open(), False,
                              "Grading period is not open")
            self.assertEquals(term.is_grading_period_past(), True,
                              "Grading period is past")
            self.assertEquals(term.term_label(), "2013,summer", "Term label")
예제 #10
0
 def get_next_term(self):
     deprecation("Use restclients.sws.term.get_next_term")
     from restclients.sws.term import get_next_term
     return get_next_term()
예제 #11
0
    def test_sws_schedule_data(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 exceptions
            term = get_previous_term()
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
            term = get_current_term()
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
            term = get_next_term()
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
            term = get_term_by_year_and_quarter(2012, 'summer')
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
            term = get_current_term()

            #Bad data, should throw exceptions
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFF",
                              term)

            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFX",
                              term)

            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "javerage",
                              term)

            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "",
                              term)

            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              " ",
                              term)

            term.year = None
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.year = 1929
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.year = 2399
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.year = 0
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.year = -2012
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.quarter = "spring"
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.quarter = "fall"
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.quarter = ""
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.quarter = " "
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)

            term.quarter = "Spring"
            self.assertRaises(DataFailureException,
                              get_schedule_by_regid_and_term,
                              "9136CCB8F66711D5BE060004AC494FFE",
                              term)
예제 #12
0
 def get_next_term(self):
     deprecation("Use restclients.sws.term.get_next_term")
     from restclients.sws.term import get_next_term
     return get_next_term()
예제 #13
0
    def test_next_quarter(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            term = get_next_term()
            self.assertTrue(term.is_summer_quarter())
            expected_quarter = "summer"
            expected_year = 2013

            self.assertEquals(term.year, expected_year,
                              "Return %s for the next year" % expected_year)

            self.assertEquals(
                term.quarter, expected_quarter,
                "Return %s for the next quarter" % expected_quarter)

            self.assertEquals(term.census_day.year, 2013)
            self.assertEquals(term.census_day.month, 7)
            self.assertEquals(term.census_day.day, 5)
            self.assertEquals(term.get_eod_census_day(),
                              datetime(2013, 7, 6, 0, 0, 0))

            self.assertEquals(term.last_day_add.year, 2013)
            self.assertEquals(term.last_day_add.month, 7)
            self.assertEquals(term.last_day_add.day, 14)
            self.assertEquals(term.get_eod_last_day_add(),
                              datetime(2013, 7, 15, 0, 0, 0))

            self.assertEquals(term.last_day_drop.year, 2013)
            self.assertEquals(term.last_day_drop.month, 8)
            self.assertEquals(term.last_day_drop.day, 11)
            self.assertEquals(term.get_eod_last_day_drop(),
                              datetime(2013, 8, 12, 0, 0, 0))

            self.assertEquals(term.first_day_quarter.year, 2013)
            self.assertEquals(term.first_day_quarter.month, 6)
            self.assertEquals(term.first_day_quarter.day, 24)
            self.assertEquals(term.get_bod_first_day(),
                              datetime(2013, 6, 24, 0, 0, 0))

            self.assertEquals(term.last_day_instruction.year, 2013)
            self.assertEquals(term.last_day_instruction.month, 8)
            self.assertEquals(term.last_day_instruction.day, 23)
            self.assertEquals(term.get_eod_last_instruction(),
                              datetime(2013, 8, 24, 0, 0, 0))

            self.assertEquals(term.aterm_last_date.year, 2013)
            self.assertEquals(term.aterm_last_date.month, 7)
            self.assertEquals(term.aterm_last_date.day, 24)

            self.assertEquals(term.bterm_first_date.year, 2013)
            self.assertEquals(term.bterm_first_date.month, 7)
            self.assertEquals(term.bterm_first_date.day, 25)
            self.assertEquals(term.get_eod_summer_aterm(),
                              datetime(2013, 7, 25, 0, 0, 0))

            self.assertEquals(term.aterm_last_day_add.year, 2013)
            self.assertEquals(term.aterm_last_day_add.month, 7)
            self.assertEquals(term.aterm_last_day_add.day, 14)
            self.assertEquals(term.get_eod_aterm_last_day_add(),
                              datetime(2013, 7, 15, 0, 0, 0))

            self.assertEquals(term.bterm_last_day_add.year, 2013)
            self.assertEquals(term.bterm_last_day_add.month, 7)
            self.assertEquals(term.bterm_last_day_add.day, 31)
            self.assertEquals(term.get_eod_bterm_last_day_add(),
                              datetime(2013, 8, 1, 0, 0, 0))

            self.assertEquals(term.last_final_exam_date.year, 2013)
            self.assertEquals(term.last_final_exam_date.month, 8)
            self.assertEquals(term.last_final_exam_date.day, 23)
            self.assertEquals(term.get_eod_last_final_exam(),
                              datetime(2013, 8, 24, 0, 0, 0))

            self.assertEquals(term.grade_submission_deadline.date().year, 2013)
            self.assertEquals(term.grade_submission_deadline.date().month, 8)
            self.assertEquals(term.grade_submission_deadline.date().day, 27)
            self.assertEquals(term.grade_submission_deadline.time().hour, 17)
            self.assertEquals(term.grade_submission_deadline.time().minute, 0)
            self.assertEquals(term.get_eod_grade_submission(),
                              datetime(2013, 8, 28, 0, 0, 0))

            self.assertEquals(term.aterm_grading_period_open.date().year, 2013)
            self.assertEquals(term.aterm_grading_period_open.date().month, 7)
            self.assertEquals(term.aterm_grading_period_open.date().day, 18)
            self.assertEquals(term.aterm_grading_period_open.time().hour, 8)
            self.assertEquals(term.aterm_grading_period_open.time().minute, 0)

            self.assertEquals(len(term.time_schedule_construction), 3)

            for tsc in term.time_schedule_construction:
                if tsc.campus == 'bothell':
                    self.assertEquals(tsc.is_on, True)

            self.assertEquals(term.is_grading_period_open(), False,
                              "Grading period is not open")
            self.assertEquals(term.is_grading_period_past(), True,
                              "Grading period is past")
            self.assertEquals(term.term_label(), "2013,summer", "Term label")