Exemple #1
0
    def test_specific_quarters(self):
        #testing bad data - get_by_year_and_quarter
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              -2012, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              0, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              1901, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              2012, 'fall')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              2012, '')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter,
                              2012, ' ')

            # Equality tests
            self.assertEquals(get_term_by_year_and_quarter(2012, 'autumn'),
                              get_term_by_year_and_quarter(2012, 'autumn'))

            self.assertEquals(get_specific_term(2012, 'autumn'),
                              get_term_by_year_and_quarter(2012, 'autumn'))

            self.assertEquals(get_specific_term(2013, 'spring'),
                              get_current_term())

            self.assertEquals(get_term_by_year_and_quarter(2013, 'spring'),
                              get_current_term())

            self.assertNotEquals(get_specific_term(2012, 'autumn'),
                                 get_term_by_year_and_quarter(2013, 'winter'))

            # Loading a term with null Registration Periods
            term = get_term_by_year_and_quarter(2015, 'autumn')
            self.assertEquals(term.registration_services_start, None)
Exemple #2
0
    def test_threaded_caching(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
                           RESTCLIENTS_DAO_CACHE_CLASS='restclients.cache_implementation.TimeSimpleCache'):

            term = get_current_term()
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
def courses(request, template="scheduler/courses.html"):
    user = UserService().get_original_user()
    if not Group().is_member_of_group(user, settings.PANOPTO_ADMIN_GROUP):
        return HttpResponseRedirect("/")

    status_code = 200

    try:
        term = get_current_term()
    except DataFailureException as ex:
        logger.exception(ex)
        raise StudentWebServiceUnavailable()

    t = loader.get_template(template)
    c = RequestContext(
        request,
        {
            "term_year": term.year,
            "term_quarter": term.quarter,
            "todays_date": time.strftime("%Y-%m-%d"),
            "canvas_host": settings.RESTCLIENTS_CANVAS_HOST if hasattr(settings, "RESTCLIENTS_CANVAS_HOST") else "",
            "panopto_server": settings.PANOPTO_SERVER if hasattr(settings, "PANOPTO_SERVER") else "",
            "STATIC_URL": settings.STATIC_URL,
        },
    )

    return HttpResponse(t.render(c), status=status_code)
def home(request, template='scheduler/home.html'):
    user = UserService().get_original_user()
    if not Group().is_member_of_group(user, settings.PANOPTO_ADMIN_GROUP):
        return HttpResponseRedirect("/")

    status_code = 200

    try:
        term = get_current_term()
    except DataFailureException as ex:
        logger.exception(ex)
        raise StudentWebServiceUnavailable()

    t = loader.get_template(template)
    c = RequestContext(request, {
        'term_year': term.year,
        'term_quarter': term.quarter,
        'todays_date': time.strftime("%Y-%m-%d"),
        'canvas_host': settings.RESTCLIENTS_CANVAS_HOST if hasattr(
            settings, 'RESTCLIENTS_CANVAS_HOST') else '',
        'panopto_server': settings.PANOPTO_SERVER if hasattr(
            settings, 'PANOPTO_SERVER') else '',
        'STATIC_URL': settings.STATIC_URL,
    })

    return HttpResponse(t.render(c), status=status_code)
Exemple #5
0
def recorders(request, template='scheduler/recorders.html'):
    user = UserService().get_original_user()
    if not Group().is_member_of_group(user, settings.PANOPTO_ADMIN_GROUP):
        return HttpResponseRedirect("/")

    status_code = 200

    try:
        term = get_current_term()
    except DataFailureException as ex:
        logger.exception(ex)
        raise StudentWebServiceUnavailable()

    t = loader.get_template(template)
    c = RequestContext(
        request, {
            'canvas_host':
            settings.RESTCLIENTS_CANVAS_HOST if hasattr(
                settings, 'RESTCLIENTS_CANVAS_HOST') else '',
            'panopto_server':
            settings.PANOPTO_SERVER
            if hasattr(settings, 'PANOPTO_SERVER') else '',
            'STATIC_URL':
            settings.STATIC_URL,
        })

    return HttpResponse(t.render(c), status=status_code)
Exemple #6
0
    def test_current_quarter(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            term = get_current_term()

            expected_quarter = "spring"
            expected_year = 2013

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

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

            self.assertEquals(term.first_day_quarter.year, 2013)
            self.assertEquals(term.first_day_quarter.month, 4)
            self.assertEquals(term.first_day_quarter.day, 1)
            self.assertEquals(term.get_bod_first_day(),
                              datetime(2013, 4, 1, 0, 0, 0))

            self.assertEquals(term.census_day.year, 2013)
            self.assertEquals(term.census_day.month, 4)
            self.assertEquals(term.census_day.day, 12)
            self.assertEquals(term.get_eod_census_day(),
                              datetime(2013, 4, 13, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period1_start(),
                              datetime(2013, 2, 15, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period2_start(),
                              datetime(2013, 3, 4, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period3_start(),
                              datetime(2013, 4, 1, 0, 0, 0))

            self.assertEquals(term.get_eod_last_final_exam(),
                              datetime(2013, 6, 15, 0, 0, 0))

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

            next_autumn_term = get_next_autumn_term(term)
            self.assertEquals(next_autumn_term.year, 2013)
            self.assertEquals(next_autumn_term.quarter, 'autumn')

            next_non_summer_term = get_next_non_summer_term(term)
            self.assertEquals(next_non_summer_term.year,
                              next_autumn_term.year)
            self.assertEquals(next_non_summer_term.quarter,
                              next_autumn_term.quarter)

            self.assertFalse(term.is_summer_quarter())
Exemple #7
0
    def test_current_quarter(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            term = get_current_term()

            expected_quarter = "spring"
            expected_year = 2013

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

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

            self.assertEquals(term.first_day_quarter.year, 2013)
            self.assertEquals(term.first_day_quarter.month, 4)
            self.assertEquals(term.first_day_quarter.day, 1)
            self.assertEquals(term.get_bod_first_day(),
                              datetime(2013, 4, 1, 0, 0, 0))

            self.assertEquals(term.census_day.year, 2013)
            self.assertEquals(term.census_day.month, 4)
            self.assertEquals(term.census_day.day, 12)
            self.assertEquals(term.get_eod_census_day(),
                              datetime(2013, 4, 13, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period1_start(),
                              datetime(2013, 2, 15, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period2_start(),
                              datetime(2013, 3, 4, 0, 0, 0))

            self.assertEquals(term.get_bod_reg_period3_start(),
                              datetime(2013, 4, 1, 0, 0, 0))

            self.assertEquals(term.get_eod_last_final_exam(),
                              datetime(2013, 6, 15, 0, 0, 0))

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

            next_autumn_term = get_next_autumn_term(term)
            self.assertEquals(next_autumn_term.year, 2013)
            self.assertEquals(next_autumn_term.quarter, 'autumn')

            next_non_summer_term = get_next_non_summer_term(term)
            self.assertEquals(next_non_summer_term.year, next_autumn_term.year)
            self.assertEquals(next_non_summer_term.quarter,
                              next_autumn_term.quarter)

            self.assertFalse(term.is_summer_quarter())
    def test_get_books_by_schedule(self):
        books = Bookstore()
        term = get_current_term()
        schedule = get_schedule_by_regid_and_term(
            'AA36CCB8F66711D5BE060004AC494FFE', term)
        schedule_books = books.get_books_for_schedule(schedule)

        self.assertEquals(len(schedule_books), 2)
        self.assertEqual(len(schedule_books['13833']), 0)
        self.assertEqual(len(schedule_books['13830']), 2)
Exemple #9
0
def get_default_date():
    """
    A hook to help with mock data testing - put the default date
    right in the middle of the "current" term.
    """
    if is_using_file_dao():
        term = get_current_term()
        first_day = term.first_day_quarter

        return first_day + timedelta(days=14)
    return datetime.now().date()
    def test_instructor_list(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term("BB000000000000000000000000009994", term)

            self.assertEquals(len(schedule.sections), 1, "Has 1 section")

            instructors = schedule.sections[0].meetings[0].instructors
Exemple #11
0
    def test_threaded_caching(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS=
                           'restclients.dao_implementation.pws.File',
                           RESTCLIENTS_DAO_CACHE_CLASS=
                           'restclients.cache_implementation.TimeSimpleCache'):

            term = get_current_term()
            get_schedule_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE',
                                           term)
    def test_instructor_list(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS=
                           'restclients.dao_implementation.pws.File'):

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term(
                "BB000000000000000000000000009994", term)

            self.assertEquals(len(schedule.sections), 1, "Has 1 section")

            instructors = schedule.sections[0].meetings[0].instructors
    def test_verba_link(self):
        books = Bookstore()

        term = get_current_term()
        schedule = get_schedule_by_regid_and_term(
            'AA36CCB8F66711D5BE060004AC494FFE', term)

        verba_link = books.get_verba_link_for_schedule(schedule)

        self.assertEquals(
            ("http://uw-seattle.verbacompare.com/m?" +
             "section_id=AB12345&quarter=spring"), verba_link,
            "Seattle student has seattle link")
Exemple #14
0
    def test_specific_quarters(self):
        #testing bad data - get_by_year_and_quarter
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, -2012, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, 0, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, 1901, 'summer')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, 2012, 'fall')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, 2012, '')

            self.assertRaises(DataFailureException,
                              get_term_by_year_and_quarter, 2012, ' ')

            # Equality tests
            self.assertEquals(get_term_by_year_and_quarter(2012, 'autumn'),
                              get_term_by_year_and_quarter(2012, 'autumn'))

            self.assertEquals(get_specific_term(2012, 'autumn'),
                              get_term_by_year_and_quarter(2012, 'autumn'))

            self.assertEquals(get_specific_term(2013, 'spring'),
                              get_current_term())

            self.assertEquals(get_term_by_year_and_quarter(2013, 'spring'),
                              get_current_term())

            self.assertNotEquals(get_specific_term(2012, 'autumn'),
                                 get_term_by_year_and_quarter(2013, 'winter'))
    def test_instructor_list(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term("BB000000000000000000000000000004", term)

            self.assertEquals(len(schedule.sections), 1, "Has 1 section")

            instructors = schedule.sections[0].meetings[0].instructors

            self.assertEquals(len(instructors), 1, "Only has the 1 instructor for independent study?")
            self.assertEquals(instructors[0].uwregid, 'FBB38FE46A7C11D5A4AE0004AC494FFE', "Only has the 1 instructor for independent study?")
Exemple #16
0
def get_default_datetime():
    """
    A hook to help with mock data testing - put the default datetime
    right in the middle of the "current" term.
    """
    if is_using_file_dao():
        term = get_current_term()
        first_day = term.first_day_quarter
        default_date = first_day + timedelta(days=14)
        return datetime(default_date.year,
                        default_date.month,
                        default_date.day,
                        0, 0, 1)
    return datetime.now()
Exemple #17
0
    def test_javerage_major(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            term = get_current_term()
            enrollement = get_enrollment_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)
            self.assertEquals(enrollement.class_level, "SENIOR")
            self.assertEquals(enrollement.is_honors, False)
            self.assertEquals(len(enrollement.majors), 1)
            self.assertEquals(enrollement.majors[0].campus, "Seattle")
            self.assertEquals(enrollement.majors[0].degree_name, "BACHELOR OF SCIENCE (APPLIED & COMPUTATIONAL MATH SCIENCES)")
            self.assertEquals(enrollement.minors[0].campus, "Seattle")
            self.assertEquals(enrollement.minors[0].name, "AMERICAN SIGN LANGUAGE")
    def test_get_books_by_schedule(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()
            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)
            schedule_books = books.get_books_for_schedule(schedule)

            self.assertEquals(len(schedule_books), 2)
            self.assertEqual(len(schedule_books['13833']), 0)
            self.assertEqual(len(schedule_books['13830']), 2)
    def test_verba_link(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)

            verba_link = books.get_verba_link_for_schedule(schedule)

            self.assertEquals("http://uw-seattle.verbacompare.com/m?section_id=AB12345&quarter=spring", verba_link, "Seattle student has seattle link")
    def test_verba_link(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)

            verba_link = books.get_verba_link_for_schedule(schedule)

            self.assertEquals("http://uw-seattle.verbacompare.com/m?section_id=AB12345&quarter=spring", verba_link, "Seattle student has seattle link")
Exemple #21
0
    def test_mock_data_fake_grading_window(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            # This rounds down to 0 days, so check by seconds :(
            hour1_delta = timedelta(hours=-1)
            hour48_delta = timedelta(hours=-48)
            now = datetime.now()

            term = get_current_term()
            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")
            self.assertEquals(term.is_grading_period_past(), False, "Grading period is not past")

            deadline = term.grade_submission_deadline
            self.assertEquals(deadline + hour1_delta > now, True, "Deadline is in the future")
            self.assertEquals(deadline + hour48_delta < now, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")

            # Also test for Spring 2013, as that's the "current" quarter
            term = get_term_by_year_and_quarter(2013, 'spring')

            self.assertEquals(term.is_grading_period_open(), True, "Grading period is open")
            self.assertEquals(term.is_grading_period_past(), False, "Grading period is not past")

            deadline = term.grade_submission_deadline
            self.assertEquals(deadline + hour1_delta > now, True, "Deadline is in the future")
            self.assertEquals(deadline + hour48_delta < now, True, "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True, "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True, "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True, "But not too far in the past")
Exemple #22
0
    def test_current_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_current_term()

            expected_quarter = "spring"
            expected_year = 2013

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

            self.assertEquals(term.quarter, expected_quarter,
                              "Return %s for the current quarter" %
                              expected_quarter)
Exemple #23
0
    def test_javerage_grades(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            term = get_current_term()
            grades = get_grades_by_regid_and_term('9136CCB8F66711D5BE060004AC494FFE', term)

            self.assertEquals(grades.term.year, 2013)
            self.assertEquals(grades.term.quarter, "spring")
            self.assertEquals(grades.user.uwnetid, "javerage")
            self.assertEquals(grades.grade_points, 30)
            self.assertEquals(grades.credits_attempted, 10)
            self.assertEquals(grades.non_grade_credits, 2)

            self.assertEquals(grades.grades[0].grade, 'CR')
            self.assertEquals(grades.grades[2].grade, '3.1')
            self.assertEquals(grades.grades[2].credits, '3.0')
            self.assertEquals(grades.grades[2].section.course_number, '121')
Exemple #24
0
    def get_terms_with_active_channels(self, channel_type):
        """
        Returns a list of all sws.Terms that have active channels.
        """
        # Check the current term, and the next 3, to see if they have
        # a channel for any course in that term.
        # when the sws term resource provides us with a timeschedule publish
        # date, use that instead of this.
        term = get_current_term()
        terms = []
        if self.term_has_active_channel(channel_type, term):
            terms.append(term)

        for i in range(3):
            term = get_term_after(term)
            if self.term_has_active_channel(channel_type, term):
                terms.append(term)

        return terms
Exemple #25
0
    def test_instructor_list(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS=
                           'restclients.dao_implementation.pws.File'):

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term(
                "BB000000000000000000000000000004", term)

            self.assertEquals(len(schedule.sections), 1, "Has 1 section")

            instructors = schedule.sections[0].meetings[0].instructors

            self.assertEquals(
                len(instructors), 1,
                "Only has the 1 instructor for independent study?")
            self.assertEquals(
                instructors[0].uwregid, 'FBB38FE46A7C11D5A4AE0004AC494FFE',
                "Only has the 1 instructor for independent study?")
    def test_dupe_slns(self):
        books = Bookstore()
        term = get_current_term()
        schedule = get_schedule_by_regid_and_term(
            'AA36CCB8F66711D5BE060004AC494FFE', term)

        schedule.sections.append(schedule.sections[0])
        schedule.sections.append(schedule.sections[0])
        schedule.sections.append(schedule.sections[0])
        schedule.sections.append(schedule.sections[0])
        schedule.sections.append(schedule.sections[0])

        verba_link = books.get_verba_url(schedule)

        self.assertEquals(
            verba_link,
            '/myuw/myuw_mobile_v.ubs?quarter=spring&sln1=13830&sln2=13833')

        schedule_books = books.get_books_for_schedule(schedule)
        self.assertEquals(len(schedule_books), 2)
Exemple #27
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')
Exemple #28
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')
    def test_sched(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()

            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)

            book_data = books.get_books_for_schedule(schedule)

            self.assertEquals(len(book_data), 2, "Has data for 2 sections")

            self.assertEquals(len(book_data["13830"]), 0, "No books for sln 13830")
            self.assertEquals(len(book_data["13833"]), 1, "one book for sln 13833")

            book = book_data["13833"][0]

            self.assertEquals(book.price, 175.00, "Has the right book price")
    def test_dupe_slns(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()
            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)

            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])

            verba_link = books.get_verba_url(schedule)

            self.assertEquals(verba_link, '/myuw/myuw_mobile_v.ubs?quarter=spring&sln1=13830&sln2=13833')

            schedule_books = books.get_books_for_schedule(schedule)
            self.assertEquals(len(schedule_books), 2)
    def test_dupe_slns(self):
        with self.settings(
            RESTCLIENTS_BOOK_DAO_CLASS='restclients.dao_implementation.book.File',
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File',
            ):

            books = Bookstore()
            term = get_current_term()
            schedule = get_schedule_by_regid_and_term('AA36CCB8F66711D5BE060004AC494FFE', term)

            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])
            schedule.sections.append(schedule.sections[0])

            verba_link = books.get_verba_url(schedule)

            self.assertEquals(verba_link, '/myuw/myuw_mobile_v.ubs?quarter=spring&sln1=13830&sln2=13833')

            books_link = books.get_books_url(schedule)
            self.assertEquals(books_link, '/myuw/myuw_mobile_beta.ubs?quarter=spring&sln1=13830&sln2=13833')
Exemple #32
0
    def test_week_of_term(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            now = datetime.now()
            term = get_current_term()

            term.first_day_quarter = now.date()

            # First day of class
            self.assertEquals(term.get_week_of_term(), 1,
                              "Term starting now in first week")
            self.assertEquals(term.get_week_of_term_for_date(now), 1,
                              "Term starting now in first week, by date")

            # Middle of the term
            start_date = now + timedelta(days=-6)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 1, "6 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 1,
                              "6 days in")

            start_date = now + timedelta(days=-7)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "7 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2,
                              "7 days in")

            start_date = now + timedelta(days=-8)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "8 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2,
                              "8 days in")

            start_date = now + timedelta(days=-13)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "13 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2,
                              "13 days in")

            start_date = now + timedelta(days=-14)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 3, "14 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 3,
                              "14 days in")

            # Before the term
            start_date = now + timedelta(days=1)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -1, "-1 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -1,
                              "-1 days")

            start_date = now + timedelta(days=7)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -1, "-7 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -1,
                              "-7 days")

            start_date = now + timedelta(days=8)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-8 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2,
                              "-8 days")

            start_date = now + timedelta(days=9)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-9 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2,
                              "-9 days")

            start_date = now + timedelta(days=14)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-14 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2,
                              "-14 days")

            start_date = now + timedelta(days=15)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -3, "-15 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -3,
                              "-15 days")
    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)
Exemple #34
0
 def get_current_term(self):
     deprecation("Use restclients.sws.term.get_current_term")
     from restclients.sws.term import get_current_term
     return get_current_term()
Exemple #35
0
 def get_current_term(self):
     deprecation("Use restclients.sws.term.get_current_term")
     from restclients.sws.term import get_current_term
     return get_current_term()
Exemple #36
0
    def test_week_of_term(self):
        with self.settings(
                RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
                RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            now = datetime.now()
            term = get_current_term()


            term.first_day_quarter = now.date()

            # First day of class
            self.assertEquals(term.get_week_of_term(), 1, "Term starting now in first week")
            self.assertEquals(term.get_week_of_term_for_date(now), 1, "Term starting now in first week, by date")

            # Middle of the term
            start_date = now + timedelta(days=-6)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 1, "6 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 1, "6 days in")

            start_date = now + timedelta(days=-7)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "7 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2, "7 days in")

            start_date = now + timedelta(days=-8)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "8 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2, "8 days in")

            start_date = now + timedelta(days=-13)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 2, "13 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 2, "13 days in")

            start_date = now + timedelta(days=-14)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), 3, "14 days in")
            self.assertEquals(term.get_week_of_term_for_date(now), 3, "14 days in")

            # Before the term
            start_date = now + timedelta(days=1)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -1, "-1 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -1, "-1 days")

            start_date = now + timedelta(days=7)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -1, "-7 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -1, "-7 days")

            start_date = now + timedelta(days=8)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-8 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2, "-8 days")

            start_date = now + timedelta(days=9)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-9 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2, "-9 days")

            start_date = now + timedelta(days=14)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -2, "-14 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -2, "-14 days")

            start_date = now + timedelta(days=15)
            term.first_day_quarter = start_date.date()
            self.assertEquals(term.get_week_of_term(), -3, "-15 days")
            self.assertEquals(term.get_week_of_term_for_date(now), -3, "-15 days")
Exemple #37
0
    def test_mock_data_fake_grading_window(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=SWSF,
                           RESTCLIENTS_PWS_DAO_CLASS=PWSF):

            # This rounds down to 0 days, so check by seconds :(
            hour1_delta = timedelta(hours=-1)
            hour48_delta = timedelta(hours=-48)
            now = datetime.now()

            term = get_current_term()
            self.assertEquals(term.is_grading_period_open(), True,
                              "Grading period is open")
            self.assertEquals(term.is_grading_period_past(), False,
                              "Grading period is not past")

            deadline = term.grade_submission_deadline
            self.assertEquals(deadline + hour1_delta > now, True,
                              "Deadline is in the future")
            self.assertEquals(deadline + hour48_delta < now, True,
                              "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True,
                              "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True,
                              "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True,
                              "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True,
                              "But not too far in the past")

            # Also test for Spring 2013, as that's the "current" quarter
            term = get_term_by_year_and_quarter(2013, 'spring')

            self.assertEquals(term.is_grading_period_open(), True,
                              "Grading period is open")
            self.assertEquals(term.is_grading_period_past(), False,
                              "Grading period is not past")

            deadline = term.grade_submission_deadline
            self.assertEquals(deadline + hour1_delta > now, True,
                              "Deadline is in the future")
            self.assertEquals(deadline + hour48_delta < now, True,
                              "But not too far in the future")

            open_diff_all = now - term.grading_period_open

            # Timezone configuration can mess this up, so using seconds
            self.assertEquals(open_diff_all.seconds > 0, True,
                              "Open date is in the past")
            self.assertEquals(open_diff_all.days < 2, True,
                              "But not too far in the past")

            open_diff_summer_a = now - term.aterm_grading_period_open
            self.assertEquals(open_diff_summer_a.seconds > 0, True,
                              "Open date is in the past")
            self.assertEquals(open_diff_summer_a.days < 2, True,
                              "But not too far in the past")
Exemple #38
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