Beispiel #1
0
 def test_get_eod_current_term_last_instruction(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-10"
         self.assertEqual(
             get_eod_current_term_last_instruction(now_request),
             datetime(2013, 6, 8, 0, 0, 0))
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(
             get_eod_current_term_last_instruction(now_request, True),
             datetime(2013, 7, 25, 0, 0, 0))
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(
             get_eod_current_term_last_instruction(now_request),
             datetime(2013, 8, 24, 0, 0, 0))
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertEqual(
             get_eod_current_term_last_instruction(now_request, True),
             datetime(2013, 8, 24, 0, 0, 0))
Beispiel #2
0
    def test_day_before_last_day_of_classes(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-06"

            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_after_grade_submission_deadline"])
            self.assertFalse(values["is_after_last_day_of_classes"])
            self.assertTrue(
                values["is_after_start_of_registration_display_period"])
            self.assertTrue(values["is_before_end_of_finals_week"])
            self.assertTrue(values["is_before_last_day_of_classes"])
            self.assertTrue(
                values["is_before_end_of_registration_display_period"])
            now = get_now(now_request)
            self.assertTrue(is_before_last_day_of_classes(now, now_request))
            self.assertTrue(
                is_after_bof_and_before_eof_reg_period(now, now_request))

            # winter
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-14"
            now = get_now(now_request)
            self.assertTrue(
                is_before_last_day_of_classes(now, now_request))
            self.assertFalse(
                is_after_last_day_of_classes(now, now_request))
Beispiel #3
0
    def test_day_after_last_day_of_classes(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            # spring
            now_request.session["myuw_override_date"] = "2013-06-08"

            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_after_grade_submission_deadline"])
            self.assertTrue(values["is_after_last_day_of_classes"])
            self.assertTrue(
                values["is_after_start_of_registration_display_period"])
            self.assertTrue(values["is_before_end_of_finals_week"])
            # This is a poorly named value - it's really last day + 1
            self.assertFalse(values["is_before_last_day_of_classes"])
            self.assertTrue(
                values["is_before_end_of_registration_display_period"])

            # 2013 winter after
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-16"
            now = get_now(now_request)
            self.assertTrue(
                is_after_last_day_of_classes(now, now_request))
            self.assertFalse(
                is_before_last_day_of_classes(now, now_request))
Beispiel #4
0
    def test_next_quarter(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}

            quarter = get_next_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "summer")

            now_request.session["myuw_override_date"] = "2013-04-01"
            quarter = get_next_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "summer")

            now_request.session["myuw_override_date"] = "2013-03-31"
            quarter = get_next_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "summer")

            now_request.session["myuw_override_date"] = "2013-06-24"
            quarter = get_next_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "autumn")

            now_request.session["myuw_override_date"] = "2013-06-23"
            quarter = get_next_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "summer")
Beispiel #5
0
    def test_json_for_evaluation(self):
        with self.settings(
            RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
            RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS,
            RESTCLIENTS_IASYSTEM_DAO_CLASS=FDAO_IAS,
        ):

            evals = get_evaluation_by_id(132136, "seattle")
            self.assertIsNotNone(evals)
            now_request = RequestFactory().get("/")
            # after show date, before open date
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-11"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNone(json_data)
            # after open date
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-13"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 1)
            self.assertEqual(json_data["close_date"], "2013-03-23T07:59:59+00:00")

            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-22"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNotNone(json_data)
            self.assertEqual(len(json_data["evals"]), 1)
            self.assertEqual(json_data["close_date"], "2013-03-23T07:59:59+00:00")
            # before hide date but after close date
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-24"
            json_data = json_for_evaluation(now_request, evals, None)
            self.assertIsNone(json_data)
Beispiel #6
0
    def test_summer_term_overlaped(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            term = Term()
            term.year = 2013
            term.quarter = "summer"
            section = Section()
            section.summer_term = "A-term"
            section.term = term

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-07-10"
            self.assertTrue(summer_term_overlaped(now_request, section))
            section.summer_term = "Full-term"
            self.assertFalse(summer_term_overlaped(now_request, section))
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-08-10"
            self.assertTrue(summer_term_overlaped(now_request, section))

            section.summer_term = "B-term"
            self.assertTrue(summer_term_overlaped(now_request, section))

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-10"
            self.assertTrue(summer_term_overlaped(now_request, 'None'))
            self.assertTrue(summer_term_overlaped(now_request, '-'))
Beispiel #7
0
 def test_in_show_grades_period(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         term = _get_term_by_year_and_quarter(2013, "winter")
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-03-27"
         self.assertTrue(in_show_grades_period(term, now_request))
         now_request.session = {}
         # spring quarter starts
         now_request.session["myuw_override_date"] = "2013-04-01"
         self.assertFalse(in_show_grades_period(term, now_request))
Beispiel #8
0
 def test_bof_1st_instruction(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-10"
         self.assertEqual(get_bof_1st_instruction(now_request), datetime(2013, 4, 1, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(get_bof_1st_instruction(now_request), datetime(2013, 6, 24, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertEqual(get_bof_1st_instruction(now_request), datetime(2013, 6, 24, 0, 0, 0))
Beispiel #9
0
 def test_is_in_summer_a_term(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertTrue(is_in_summer_a_term(now_request))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertFalse(is_in_summer_a_term(now_request))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-03-10"
         self.assertFalse(is_in_summer_a_term(now_request))
Beispiel #10
0
 def test_eof_last_final_exam(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-03-10"
         self.assertEqual(get_eof_last_final_exam(now_request), datetime(2013, 3, 23, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(get_eof_last_final_exam(now_request, True), datetime(2013, 7, 25, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertEqual(get_eof_last_final_exam(now_request), datetime(2013, 8, 24, 0, 0, 0))
Beispiel #11
0
 def test_eof_7d_after_class_start(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-10"
         self.assertEqual(get_eof_7d_after_class_start(now_request), datetime(2013, 4, 9, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(get_eof_7d_after_class_start(now_request), datetime(2013, 7, 2, 0, 0, 0))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertEqual(get_eof_7d_after_class_start(now_request), datetime(2013, 7, 2, 0, 0, 0))
Beispiel #12
0
 def test_term_matched(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertTrue(term_matched(now_request, "A-term"))
         self.assertFalse(term_matched(now_request, "Full-term"))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertTrue(term_matched(now_request, "B-term"))
         self.assertTrue(term_matched(now_request, "Full-term"))
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-03-10"
         self.assertTrue(term_matched(now_request, "None"))
         self.assertTrue(term_matched(now_request, "-"))
Beispiel #13
0
    def test_filter_past(self):
        request = RequestFactory().get("/")
        request.session = {}
        request.session["myuw_override_date"] = "2011-01-01"

        past = Event()
        past.add('dtstart', date(2010, 01, 01))
        past.add('dtend', date(2010, 12, 31))
        past['summary'] = "Past Event"

        events = AcademicEvents().filter_past_events(request, [past])
        self.assertEquals(len(events), 0)

        request.session["myuw_override_date"] = "2010-12-30"
        events = AcademicEvents().filter_past_events(request, [past])
        self.assertEquals(len(events), 1)
Beispiel #14
0
 def test_is_past(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         quarter = get_quarter(2013, "autumn")
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2014-01-01"
         self.assertTrue(is_past(quarter, now_request))
Beispiel #15
0
 def test_is_after_7d_before_last_instruction(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         # spring
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-30"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-31"
         values = get_card_visibilty_date_values(now_request)
         self.assertTrue(values["is_after_7d_before_last_instruction"])
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-06-24"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
         # summer a-term
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-07-10"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-07-11"
         values = get_card_visibilty_date_values(now_request)
         self.assertTrue(values["is_after_7d_before_last_instruction"])
         # b-term start
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-07-19"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
         # summer b-term or full-term
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-08-09"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-08-10"
         values = get_card_visibilty_date_values(now_request)
         self.assertTrue(values["is_after_7d_before_last_instruction"])
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2012-08-22"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_7d_before_last_instruction"])
Beispiel #16
0
 def test_get_bod_7d_before_last_instruction(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-05-10"
         self.assertEqual(get_bod_7d_before_last_instruction(now_request),
                          datetime(2013, 5, 31, 0, 0, 0))
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-07-10"
         self.assertEqual(get_bod_7d_before_last_instruction(now_request),
                          datetime(2013, 7, 17, 0, 0, 0))
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-08-10"
         self.assertEqual(get_bod_7d_before_last_instruction(now_request),
                          datetime(2013, 8, 16, 0, 0, 0))
Beispiel #17
0
    def test_get_grad_petition(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_GRAD_DAO_CLASS=FDAO_GRA):
            now_request = RequestFactory().get("/")

            petition_reqs = get_petition_by_regid(
                '10000000000000000000000000000003')
            self.assertEquals(len(petition_reqs), 0)
            self.assertIsNone(petition_to_json(petition_reqs, now_request))

            petition_reqs = get_petition_by_regid(
                '10000000000000000000000000000002')
            self.assertIsNotNone(petition_reqs)
            self.assertEquals(len(petition_reqs), 7)

            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-10"
            json_data = petition_to_json(petition_reqs, now_request)
            self.assertEquals(len(json_data), 7)
            peti = json_data[0]
            self.assertEqual(peti["dept_recommend"], "Pending")
            self.assertEqual(peti["gradschool_decision"], "Pending")
            peti = json_data[1]
            self.assertEquals(peti["decision_date"], "2013-04-10T00:00:00")
            self.assertEqual(peti["dept_recommend"], "Withdraw")
            self.assertEqual(peti["gradschool_decision"], "Withdraw")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-25"
            json_data = petition_to_json(petition_reqs, now_request)
            self.assertEquals(len(json_data), 3)
            peti = json_data[0]
            self.assertEqual(peti["dept_recommend"], "Pending")
            self.assertEqual(peti["gradschool_decision"], "Pending")
            peti = json_data[1]
            self.assertIsNone(peti["decision_date"])
            self.assertEqual(peti["dept_recommend"], "Deny")
            self.assertEqual(peti["gradschool_decision"], "Pending")
            peti = json_data[2]
            self.assertIsNone(peti["decision_date"])
            self.assertEqual(peti["dept_recommend"], "Approve")
            self.assertEqual(peti["gradschool_decision"], "Pending")
Beispiel #18
0
    def test_apply_showhide(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            # within 14 days after open
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-01-15"
            notices = apply_showhide(
                now_request,
                categorize_notices(get_notices_by_regid(regid)))
            notice = notices[9]
            self.assertTrue(notice.is_critical)

            # after 14 days after open
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-01-16"
            notices = apply_showhide(
                now_request,
                categorize_notices(get_notices_by_regid(regid)))
            notice = notices[9]
            self.assertFalse(notice.is_critical)

            # before 14 days before close
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-02-12"
            notices = apply_showhide(
                now_request,
                categorize_notices(get_notices_by_regid(regid)))
            notice = notices[9]
            self.assertFalse(notice.is_critical)

            # within 14 days before close
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-02-13"
            notices = apply_showhide(
                now_request,
                categorize_notices(get_notices_by_regid(regid)))
            notice = notices[9]
            self.assertTrue(notice.is_critical)
Beispiel #19
0
 def test_display_name(self):
     with self.settings(RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-09-20"
         user = User.objects.create_user(username='javerage',
                                         email='none@example.com',
                                         password='')
         now_request.user = user
         UserServiceMiddleware().process_request(now_request)
         name = get_display_name_of_current_user()
         self.assertEqual(name, 'J. Average Student')
Beispiel #20
0
    def test_current_quarter(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}

            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")

            now_request.session["myuw_override_date"] = "2013-04-01"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")

            now_request.session["myuw_override_date"] = "2013-03-25"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "winter")

            now_request.session["myuw_override_date"] = "2013-03-26"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "winter")

            now_request.session["myuw_override_date"] = "2013-03-27"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")

            now_request.session["myuw_override_date"] = "2013-03-31"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")

            now_request.session["myuw_override_date"] = "2013-06-24"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "summer")

            # Spring's grade submission deadline is today, so we're not after
            # that, which is why this is an exception to the rule
            now_request.session["myuw_override_date"] = "2013-06-23"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")

            now_request.session["myuw_override_date"] = "2013-06-18"
            quarter = get_current_quarter(now_request)
            self.assertEquals(quarter.year, 2013)
            self.assertEquals(quarter.quarter, "spring")
Beispiel #21
0
    def test_comparison_date(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            no_override = get_comparison_date(now_request)
            self.assertEquals(no_override.year, 2013)
            self.assertEquals(no_override.month, 4)
            self.assertEquals(no_override.day, 15)

            now_request.session["myuw_override_date"] = "2014-01-01"
            no_override = get_comparison_date(now_request)
            self.assertEquals(no_override.year, 2014)
            self.assertEquals(no_override.month, 1)
            self.assertEquals(no_override.day, 1)
Beispiel #22
0
 def test_13_days_before_period1_registration(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
         # Using winter term dates, because spring/summer dates
         # are too close together
         now_request = RequestFactory().get("/")
         now_request.session = {}
         now_request.session["myuw_override_date"] = "2013-02-02"
         values = get_card_visibilty_date_values(now_request)
         self.assertFalse(values["is_after_grade_submission_deadline"])
         self.assertFalse(values["is_after_last_day_of_classes"])
         self.assertTrue(
             values["is_after_start_of_registration_display_period"])
         self.assertTrue(values["is_before_end_of_finals_week"])
         # This is a poorly named value - it's really last day + 1
         self.assertTrue(values["is_before_last_day_of_classes"])
         self.assertTrue(
             values["is_before_end_of_registration_display_period"])
Beispiel #23
0
    def test_efs_before_end(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-09-01"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            cur_term = get_current_quarter(now_request)
            fall_efs_schedule = _get_schedule(regid, cur_term)
            self.assertIsNotNone(fall_efs_schedule)
            self.assertEqual(len(fall_efs_schedule.sections), 2)
Beispiel #24
0
    def test_day_of_grade_submission_deadline(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            # We need to test in winter, because spring's grade submission
            # deadline is replaced to test grade submission
            now_request.session["myuw_override_date"] = "2013-03-26"

            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_after_grade_submission_deadline"])
            self.assertTrue(values["is_after_last_day_of_classes"])
            self.assertFalse(
                values["is_after_start_of_registration_display_period"])
            self.assertFalse(values["is_before_end_of_finals_week"])
            # This is a poorly named value - it's really last day + 1
            self.assertFalse(values["is_before_last_day_of_classes"])
            self.assertFalse(
                values["is_before_end_of_registration_display_period"])
Beispiel #25
0
    def test_last_final_exam_day(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")

            # spring
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-14"
            values = get_card_visibilty_date_values(now_request)
            self.assertTrue(values["is_after_last_day_of_classes"])
            self.assertTrue(values["is_before_end_of_finals_week"])
            now = get_comparison_datetime(now_request)
            self.assertTrue(is_before_eof_finals_week(now, now_request))
            self.assertFalse(is_before_last_day_of_classes(now, now_request))

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-15"
            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_before_end_of_finals_week"])
            self.assertFalse(values["is_before_last_day_of_classes"])
            now = get_comparison_datetime(now_request)
            self.assertFalse(is_before_eof_finals_week(now, now_request))

            # autumn
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-13"
            values = get_card_visibilty_date_values(now_request)
            self.assertTrue(values["is_before_end_of_finals_week"])
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-14"
            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_before_end_of_finals_week"])
            now = get_comparison_datetime(now_request)
            self.assertFalse(is_before_eof_finals_week(now, now_request))

            # winter
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-22"
            values = get_card_visibilty_date_values(now_request)
            self.assertTrue(values["is_before_end_of_finals_week"])
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-03-23"
            values = get_card_visibilty_date_values(now_request)
            self.assertFalse(values["is_before_end_of_finals_week"])
            now = get_comparison_datetime(now_request)
            self.assertFalse(is_before_eof_finals_week(now, now_request))
Beispiel #26
0
    def test_js_overrides(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-01"

            # Swapping one true, and one false value
            # from the test_first_day test
            now_request.session["myuw_after_submission"] = True
            now_request.session["myuw_after_reg"] = False

            values = get_card_visibilty_date_values(now_request)
            self.assertTrue(values["is_after_grade_submission_deadline"])
            self.assertFalse(values["is_after_last_day_of_classes"])
            self.assertFalse(
                values["is_after_start_of_registration_display_period"])
            self.assertTrue(values["is_before_end_of_finals_week"])
            self.assertTrue(values["is_before_last_day_of_classes"])
            self.assertFalse(
                values["is_before_end_of_registration_display_period"])
Beispiel #27
0
    def test_winter_quarter_schedule(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-11-30"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            next_term = get_next_quarter(now_request)
            self.assertEqual(next_term.year, 2014)
            self.assertEqual(next_term.quarter, "winter")
            self.assertFalse(cur_term == next_term)

            winter2014_sche = _get_schedule(regid, next_term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
Beispiel #28
0
    def test_efs_after_end_of_early_start(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-09-20"
            cur_term = get_current_quarter(now_request)
            self.assertEqual(cur_term.year, 2013)
            self.assertEqual(cur_term.quarter, "autumn")

            user = User.objects.create_user(username='javerage',
                                            email='none@example.com',
                                            password='')

            now_request.user = user
            UserServiceMiddleware().process_request(now_request)
            cur_term = get_current_quarter(now_request)
            fall_efs_schedule = get_schedule_by_term(now_request, cur_term)
            self.assertIsNotNone(fall_efs_schedule)
            self.assertEqual(len(fall_efs_schedule.sections), 1)
Beispiel #29
0
    def test_get_registered_future_quarters(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            now_request = RequestFactory().get("/")
            now_request.session = {}

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term1 = get_specific_term(2013, "summer")
            schedule1 = _get_schedule(regid, term1)
            self.assertEqual(len(schedule1.sections), 3)

            term2 = get_specific_term(2013, "autumn")
            schedule2 = _get_schedule(regid, term2)
            self.assertEqual(len(schedule2.sections), 2)

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            terms = _get_registered_future_quarters(now_request, None, None)
            self.assertEqual(len(terms), 0)

            # MUWM-3010
            # Baseline pre-summer
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-04-01"

            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 3)
            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "a-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Summer")
            self.assertEqual(terms[1]['summer_term'], "b-term")

            self.assertTrue(terms[2]['year'] == 2013)
            self.assertEqual(terms[2]['quarter'], "Autumn")
            self.assertEqual(terms[2]['summer_term'], "")

            # Summer has started - so no a-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-06-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 2)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Summer")
            self.assertEqual(terms[0]['summer_term'], "b-term")

            self.assertTrue(terms[1]['year'] == 2013)
            self.assertEqual(terms[1]['quarter'], "Autumn")
            self.assertEqual(terms[1]['summer_term'], "")

            # Summer b-term has started - so no a-term or b-term
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-07-30"
            terms = _get_registered_future_quarters(now_request, schedule1,
                                                    schedule2)
            self.assertTrue(len(terms) == 1)

            self.assertTrue(terms[0]['year'] == 2013)
            self.assertEqual(terms[0]['quarter'], "Autumn")
            self.assertEqual(terms[0]['summer_term'], "")

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters =\
                _get_registered_future_quarters(now_request,
                                                winter2014_sche,
                                                None)

            self.assertEqual(len(registered_future_quarters), 1)
            term1 = registered_future_quarters[0]
            self.assertEqual(term1["quarter"], "Winter")
            self.assertEqual(term1["year"], 2014)
            self.assertEqual(term1["section_count"], 5)
Beispiel #30
0
    def test_save_seen_registration_obj(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-12-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2014, "winter")
            winter2014_sche = _get_schedule(regid, term)
            self.assertIsNotNone(winter2014_sche)
            self.assertEqual(len(winter2014_sche.sections), 5)
            registered_future_quarters = _get_registered_future_quarters(
                now_request,  winter2014_sche, None)

            user, created = User.objects.get_or_create(
                uwnetid='javerage',
                uwregid='9136CCB8F66711D5BE060004AC494FFE')

            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2014)
            self.assertEqual(model.quarter, "Winter")
            self.assertEqual(model.summer_term, "F")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2014,
                                                   quarter="Winter",
                                                   summer_term="F",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           registered_future_quarters[0])
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2014,
                                                    quarter="Winter",
                                                    summer_term="F",
                                                    )
            self.assertEqual(len(qset1), 1)

            now_request = RequestFactory().get("/")
            now_request.session = {}
            now_request.session["myuw_override_date"] = "2013-5-10"

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            term = get_specific_term(2013, "summer")
            summer2013_sche = _get_schedule(regid, term)
            self.assertIsNotNone(summer2013_sche)
            self.assertEqual(len(summer2013_sche.sections), 3)
            registered_future_quarters = _get_registered_future_quarters(
                now_request,  summer2013_sche, None)
            self.assertEqual(len(registered_future_quarters), 2)

            quarter = registered_future_quarters[0]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "A")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2013,
                                                   quarter="Summer",
                                                   summer_term="A",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2013,
                                                    quarter="Summer",
                                                    summer_term="A",
                                                    )
            self.assertEqual(len(qset1), 1)

            quarter = registered_future_quarters[1]
            model, created, now_datetime, summer_term =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertTrue(created)
            self.assertEqual(model.user.uwnetid, "javerage")
            self.assertEqual(model.year, 2013)
            self.assertEqual(model.quarter, "Summer")
            self.assertEqual(model.summer_term, "B")
            qset = SeenRegistration.objects.filter(user=user,
                                                   year=2013,
                                                   quarter="Summer",
                                                   summer_term="B",
                                                   )
            self.assertEqual(len(qset), 1)

            model1, created1, now_datetime1, summer_term1 =\
                save_seen_registration_obj(user, now_request,
                                           quarter)
            self.assertFalse(created1)
            qset1 = SeenRegistration.objects.filter(user=user,
                                                    year=2013,
                                                    quarter="Summer",
                                                    summer_term="B",
                                                    )
            self.assertEqual(len(qset1), 1)