def test_last_final_exam_day(self): # spring now_request = self.get_request_for_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 = self.get_request_for_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 values = self.get_visibility_for_date('2013-12-13') self.assertTrue(values["is_before_end_of_finals_week"]) now_request = self.get_request_for_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 values = self.get_visibility_for_date('2013-03-22') self.assertTrue(values["is_before_end_of_finals_week"]) now_request = self.get_request_for_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))
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_comparison_datetime(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_comparison_datetime(now_request) self.assertTrue( is_before_last_day_of_classes(now, now_request)) self.assertFalse( is_after_last_day_of_classes(now, now_request))
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))
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 = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-03-16" now = get_comparison_datetime(now_request) self.assertTrue( is_after_last_day_of_classes(now, now_request)) self.assertFalse( is_before_last_day_of_classes(now, now_request))
def leave_to_json(req_data, request): """ Convert the leave request list object into JSON and remove the list item if it should not be shown. """ if req_data is None or len(req_data) == 0: return None result = [] now = get_comparison_datetime(request) for item in req_data: if item.is_status_approved(): # show until the end of the last instruction day of the leave term append_if_fn_apply(get_eod_specific_quarter_last_instruction, result, item, now) continue if item.is_status_denied() or item.is_status_paid(): # show until the end of the leave term append_if_fn_apply(get_eod_specific_quarter, result, item, now) continue if item.is_status_requested(): # show during the status result.append(item.json_data()) continue if item.is_status_withdrawn(): # show until eof the following quarter append_if_fn_apply(get_eod_specific_quarter_after, result, item, now) continue if len(result) == 0: return None return result
def GET(self, request, year, quarter): timer = Timer() try: no_myplan_access = during_myplan_peak_load( get_comparison_datetime(request), request) if no_myplan_access: log_msg(logger, timer, "No MyPlan access during their peak load, abort!") return HttpResponse('[]') plan = get_plan(regid=get_regid_of_current_user(), year=year, quarter=quarter.lower(), terms=1) base_json = plan.json_data() has_ready_courses = False has_unready_courses = False ready_count = 0 unready_count = 0 has_sections = False for course in base_json["terms"][0]["courses"]: if course["registrations_available"]: has_ready_courses = True ready_count = ready_count + 1 for section in course["sections"]: has_sections = True curriculum = course["curriculum_abbr"].upper() section_id = section["section_id"].upper() label = "%s,%s,%s,%s/%s" % (year, quarter.lower(), curriculum, course["course_number"], section_id ) sws_section = get_section_by_label(label) section["section_data"] = sws_section.json_data() else: if len(course["sections"]): has_sections = True has_unready_courses = True unready_count = unready_count + 1 base_json["terms"][0]["has_ready_courses"] = has_ready_courses base_json["terms"][0]["has_unready_courses"] = has_unready_courses base_json["terms"][0]["ready_count"] = ready_count base_json["terms"][0]["unready_count"] = unready_count base_json["terms"][0]["has_sections"] = has_sections log_success_response(logger, timer) return HttpResponse(json.dumps(base_json)) except Exception: log_err(logger, timer, traceback.format_exc()) return HttpResponse('[]')
def test_day_before_last_day_of_classes(self): now_request = self.get_request_for_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_comparison_datetime(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 = self.get_request_for_date('2013-03-14') now = get_comparison_datetime(now_request) self.assertTrue(is_before_last_day_of_classes(now, now_request)) self.assertFalse(is_after_last_day_of_classes(now, now_request))
def in_coursevel_fetch_window(request): """ @return true if the comparison date is inside the default show window range of course eval """ now = get_comparison_datetime(request) logger.debug( "Is %s in_coursevel_fetch_window (%s, %s)=>%s" % (now, _get_default_show_start(request), _get_default_show_end(request), (now >= _get_default_show_start(request) and now < _get_default_show_end(request)))) return (now >= _get_default_show_start(request) and now < _get_default_show_end(request))
def GET(self, request, year, quarter): timer = Timer() try: no_myplan_access = during_myplan_peak_load( get_comparison_datetime(request), request) if no_myplan_access: log_msg(logger, timer, "No MyPlan access during their peak load, abort!") return HttpResponse('[]') plan = get_plan(regid=get_regid_of_current_user(), year=year, quarter=quarter.lower(), terms=1) base_json = plan.json_data() has_ready_courses = False has_unready_courses = False ready_count = 0 unready_count = 0 has_sections = False for course in base_json["terms"][0]["courses"]: if course["registrations_available"]: has_ready_courses = True ready_count = ready_count + 1 for section in course["sections"]: has_sections = True curriculum = course["curriculum_abbr"].upper() section_id = section["section_id"].upper() label = "%s,%s,%s,%s/%s" % (year, quarter.lower( ), curriculum, course["course_number"], section_id) sws_section = get_section_by_label(label) section["section_data"] = sws_section.json_data() else: if len(course["sections"]): has_sections = True has_unready_courses = True unready_count = unready_count + 1 base_json["terms"][0]["has_ready_courses"] = has_ready_courses base_json["terms"][0]["has_unready_courses"] = has_unready_courses base_json["terms"][0]["ready_count"] = ready_count base_json["terms"][0]["unready_count"] = unready_count base_json["terms"][0]["has_sections"] = has_sections log_success_response(logger, timer) return HttpResponse(json.dumps(base_json)) except Exception: log_err(logger, timer, traceback.format_exc()) return HttpResponse('[]')
def in_coursevel_fetch_window(request): """ @return true if the comparison date is inside the default show window range of course eval """ now = get_comparison_datetime(request) logger.debug("Is %s in_coursevel_fetch_window (%s, %s)=>%s" % ( now, _get_default_show_start(request), _get_default_show_end(request), (now >= _get_default_show_start(request) and now < _get_default_show_end(request)))) return (now >= _get_default_show_start(request) and now < _get_default_show_end(request))
def test_day_before_last_day_of_classes(self): now_request = self.get_request_for_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_comparison_datetime(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 = self.get_request_for_date('2013-03-14') now = get_comparison_datetime(now_request) self.assertTrue( is_before_last_day_of_classes(now, now_request)) self.assertFalse( is_after_last_day_of_classes(now, now_request))
def test_day_after_last_day_of_classes(self): values = self.get_visibility_for_date('2013-06-08') 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 = self.get_request_for_date('2013-03-16') now = get_comparison_datetime(now_request) self.assertTrue(is_after_last_day_of_classes(now, now_request)) self.assertFalse(is_before_last_day_of_classes(now, now_request))
def json_for_evaluation(request, evaluations, section): """ @return the json format of only the evaluations that should be shown; [] if none should be displaued at the moment; or None if error in fetching data. This function should not be called if not in in_coursevel_fetch_window. """ if evaluations is None: return None # to compare with timezone aware datetime object now = _get_local_tz().localize(get_comparison_datetime(request)) pws = PWS() json_data = [] for evaluation in evaluations: if summer_term_overlaped(request, section): logger.debug( "Is %s within eval open close dates (%s, %s)==>%s" % ( now, evaluation.eval_open_date, evaluation.eval_close_date, (now >= evaluation.eval_open_date and now < evaluation.eval_close_date))) if evaluation.is_completed or\ now < evaluation.eval_open_date or\ now >= evaluation.eval_close_date: continue json_item = { 'instructors': [], 'url': evaluation.eval_url, 'close_date': datetime_str(evaluation.eval_close_date), 'is_multi_instr': len(evaluation.instructor_ids) > 1 } for eid in evaluation.instructor_ids: instructor_json = {} instructor = pws.get_person_by_employee_id(eid) instructor_json['instructor_name'] = instructor.display_name instructor_json['instructor_title'] = instructor.title1 json_item['instructors'].append(instructor_json) json_data.append(json_item) return json_data
def json_for_evaluation(request, evaluations, section): """ @return the json format of only the evaluations that should be shown; [] if none should be displaued at the moment; or None if error in fetching data. This function should not be called if not in in_coursevel_fetch_window. """ if evaluations is None: return None # to compare with timezone aware datetime object now = _get_local_tz().localize(get_comparison_datetime(request)) pws = PWS() json_data = [] for evaluation in evaluations: if summer_term_overlaped(request, section): logger.debug( "Is %s within eval open close dates (%s, %s)==>%s" % (now, evaluation.eval_open_date, evaluation.eval_close_date, (now >= evaluation.eval_open_date and now < evaluation.eval_close_date))) if evaluation.is_completed or\ now < evaluation.eval_open_date or\ now >= evaluation.eval_close_date: continue json_item = { 'instructors': [], 'url': evaluation.eval_url, 'close_date': datetime_str(evaluation.eval_close_date), 'is_multi_instr': len(evaluation.instructor_ids) > 1 } for eid in evaluation.instructor_ids: instructor_json = {} instructor = pws.get_person_by_employee_id(eid) instructor_json['instructor_name'] = instructor.display_name instructor_json['instructor_title'] = instructor.title1 json_item['instructors'].append(instructor_json) json_data.append(json_item) return json_data
def test_day_after_last_day_of_classes(self): values = self.get_visibility_for_date('2013-06-08') 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 = self.get_request_for_date('2013-03-16') now = get_comparison_datetime(now_request) self.assertTrue( is_after_last_day_of_classes(now, now_request)) self.assertFalse( is_before_last_day_of_classes(now, now_request))
def add_date_term_info(request, context): actual_now = get_default_datetime() used_now = get_comparison_datetime(request) context["actual_now_date"] = str(actual_now) context["effective_now_date"] = str(used_now) context["is_using_mock_data"] = is_using_file_dao() try: actual_term = get_term_by_date(actual_now.date()) context["actual_now_term_year"] = actual_term.year context["actual_now_term_quarter"] = actual_term.quarter except Exception as ex: pass try: used_term = get_term_by_date(used_now.date()) context["effective_now_term_year"] = used_term.year context["effective_now_term_quarter"] = used_term.quarter except Exception as ex: pass
def degree_to_json(req_data, request): """ Convert the degree request list object into JSON and remove the list item if it should not be shown. """ if req_data is None or len(req_data) == 0: return None result = [] now = get_comparison_datetime(request) for item in req_data: # Awaiting Dept Action, # Awaiting Dept Action (Final Exam), # Awaiting Dept Action (General Exam) # Recommended by Dept if item.is_status_await() or\ item.is_status_recommended(): # show during the status result.append(item.json_data()) continue if item.is_status_graduated() or\ item.is_status_candidacy() or\ item.is_status_not_graduate(): # show until eof the following quarter if now < get_eod_specific_quarter_after(item.target_award_year, item.target_award_quarter): result.append(item.json_data()) continue # For other statuses: if is_before_eof_2weeks_since_decision_date(item.decision_date, now): # show for 2 weeks after the decision date result.append(item.json_data()) if len(result) == 0: return None return result
def petition_to_json(req_data, request): """ Convert the petition request list object into JSON and remove the list item if it should not be shown. """ if req_data is None or len(req_data) == 0: return None result = [] now = get_comparison_datetime(request) for item in req_data: if item.is_gs_pending(): # in all three status of dept # show during the status result.append(item.json_data()) continue # For other statuses: if is_before_eof_2weeks_since_decision_date(item.decision_date, now): # show for 2 weeks after the decision date result.append(item.json_data()) if len(result) == 0: return None return result
def get_card_visibilty_date_values(request=None): values = get_values_by_date(get_comparison_datetime(request), request) set_js_overrides(request, values) return values
def in_show_grades_period(term, request): return (term is not None and request is not None and get_comparison_datetime(request) < get_bod_quarter_after(term))
def test_first_day(self): # spring, before grade submission values = self.get_visibility_for_date('2013-03-26') self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_first_day_of_term"]) # spring, after grade submission now_request = self.get_request_for_date('2013-03-27') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) self.assertTrue(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_bof_term(now, now_request)) # spring, before instruction begins now_request = self.get_request_for_date('2013-03-31') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_bof_term(now, now_request)) # spring, instruction begins now_request = self.get_request_for_date('2013-04-01') 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.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"]) self.assertFalse(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_bof_term(now, now_request)) # autumn values = self.get_visibility_for_date('2012-08-21') self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_first_day_of_term"]) values = self.get_visibility_for_date('2012-08-22') self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) self.assertTrue(values["is_before_first_day_of_term"]) values = self.get_visibility_for_date('2012-09-24') self.assertFalse(values["is_before_first_day_of_term"]) values = self.get_visibility_for_date('2012-09-23') self.assertTrue(values["is_before_first_day_of_term"]) # winter values = self.get_visibility_for_date('2013-12-17') self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) values = self.get_visibility_for_date('2013-12-18') self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) values = self.get_visibility_for_date('2013-01-07') self.assertFalse(values["is_before_first_day_of_term"]) values = self.get_visibility_for_date('2013-01-06') self.assertTrue(values["is_before_first_day_of_term"]) # summer values = self.get_visibility_for_date('2012-06-12') self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) values = self.get_visibility_for_date('2012-06-13') self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) values = self.get_visibility_for_date('2012-06-18') self.assertFalse(values["is_before_first_day_of_term"]) values = self.get_visibility_for_date('2012-06-17') self.assertTrue(values["is_before_first_day_of_term"])
def test_is_before_eof_7days_of_term(self): values = self.get_visibility_for_date('2013-03-26') self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_eof_7days_of_term"]) # spring values = self.get_visibility_for_date('2013-03-27') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2013-04-08') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2013-04-09') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2012-08-21') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) # autumn values = self.get_visibility_for_date('2012-08-22') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2012-10-01') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2012-10-02') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_eof_7d_after_class_start(now, now_request)) values = self.get_visibility_for_date('2012-12-18') self.assertFalse(values["is_after_grade_submission_deadline"]) # winter values = self.get_visibility_for_date('2012-12-19') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2013-01-14') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2013-01-15') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_eof_7d_after_class_start(now, now_request)) values = self.get_visibility_for_date('2012-06-12') self.assertFalse(values["is_after_grade_submission_deadline"]) # summer values = self.get_visibility_for_date('2012-06-13') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2012-06-25') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_eof_7d_after_class_start(now, now_request)) # A-term, Full-term now_request = self.get_request_for_date('2012-06-26') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_eof_7d_after_class_start(now, now_request)) # B-term now_request = self.get_request_for_date('2012-07-26') values = get_card_visibilty_date_values(now_request) now = get_comparison_datetime(now_request) self.assertFalse(is_before_eof_7d_after_class_start(now, now_request))
def test_is_before_eof_7days_of_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-03-26" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_eof_7days_of_term"]) # spring now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-03-27" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-08" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-09" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-08-21" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) # autumn 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.assertTrue(values["is_before_eof_7days_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-10-01" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-10-02" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-12-18" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) # winter now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-12-19" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-01-14" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-01-15" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-12" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) # summer now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-13" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-25" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) # A-term, Full-term now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-26" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) # B-term now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-07-26" values = get_card_visibilty_date_values(now_request) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request))
def test_is_before_eof_7days_of_term(self): values = self.get_visibility_for_date('2013-03-26') self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_eof_7days_of_term"]) # spring values = self.get_visibility_for_date('2013-03-27') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2013-04-08') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2013-04-09') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2012-08-21') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_grade_submission_deadline"]) # autumn values = self.get_visibility_for_date('2012-08-22') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2012-10-01') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2012-10-02') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) values = self.get_visibility_for_date('2012-12-18') self.assertFalse(values["is_after_grade_submission_deadline"]) # winter values = self.get_visibility_for_date('2012-12-19') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2013-01-14') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) now_request = self.get_request_for_date('2013-01-15') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) values = self.get_visibility_for_date('2012-06-12') self.assertFalse(values["is_after_grade_submission_deadline"]) # summer values = self.get_visibility_for_date('2012-06-13') self.assertTrue(values["is_before_eof_7days_of_term"]) now_request = self.get_request_for_date('2012-06-25') values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue( is_before_eof_7d_after_class_start(now, now_request)) # A-term, Full-term now_request = self.get_request_for_date('2012-06-26') values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_eof_7days_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request)) # B-term now_request = self.get_request_for_date('2012-07-26') values = get_card_visibilty_date_values(now_request) now = get_comparison_datetime(now_request) self.assertFalse( is_before_eof_7d_after_class_start(now, now_request))
def test_first_day(self): with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS): now_request = RequestFactory().get("/") # spring, before grade submission now_request.session = {} now_request.session["myuw_override_date"] = "2013-03-26" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_first_day_of_term"]) # spring, after grade submission now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-03-27" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) self.assertTrue(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_bof_term(now, now_request)) # spring, before instruction begins now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-03-31" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertTrue(is_before_bof_term(now, now_request)) # spring, instruction begins now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-01" 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.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"]) self.assertFalse(values["is_before_first_day_of_term"]) now = get_comparison_datetime(now_request) self.assertFalse(is_before_bof_term(now, now_request)) # autumn now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-08-21" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) self.assertFalse(values["is_before_first_day_of_term"]) 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_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) self.assertTrue(values["is_before_first_day_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-09-24" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_first_day_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-09-23" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_first_day_of_term"]) # winter now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-12-17" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-12-18" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-01-07" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_first_day_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2013-01-06" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_first_day_of_term"]) # summer now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-12" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_after_last_day_of_classes"]) self.assertFalse(values["is_after_grade_submission_deadline"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-13" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_after_last_day_of_classes"]) self.assertTrue(values["is_after_grade_submission_deadline"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-18" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["is_before_first_day_of_term"]) now_request = RequestFactory().get("/") now_request.session = {} now_request.session["myuw_override_date"] = "2012-06-17" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["is_before_first_day_of_term"])
def test_myplan_peak_loads(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-14 06:00:00" values = get_card_visibilty_date_values(now_request) self.assertFalse(values["myplan_peak_load"]) now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-15 05:29:59" now = get_comparison_datetime(now_request) self.assertFalse(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-15 05:30:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-16 06:29:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-05-10 06:29:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-05-10 06:30:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-05-22 06:30:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-05-23 06:29:00" now = get_comparison_datetime(now_request) self.assertTrue(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-06-23 06:30:01" now = get_comparison_datetime(now_request) self.assertFalse(during_myplan_peak_load(now, now_request)) now_request.session = {} now_request.session["myuw_override_date"] = "2013-02-15 06:00:00" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["myplan_peak_load"]) now_request.session = {} now_request.session["myuw_override_date"] = "2013-04-15 06:00:00" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["myplan_peak_load"]) now_request.session = {} now_request.session["myuw_override_date"] = "2013-05-11 06:00:00" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["myplan_peak_load"]) now_request.session = {} now_request.session["myuw_override_date"] = "2013-06-23 06:00:00" values = get_card_visibilty_date_values(now_request) self.assertTrue(values["myplan_peak_load"])