예제 #1
0
 def test_get_close_date(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         notices = categorize_notices(get_notices_by_regid(regid))
         notice = notices[9]
         close_date = get_close_date(notice)
         close = timezone.get_current_timezone().localize(
             datetime(2013, 2, 28, 0, 0, 0)).astimezone(pytz.utc)
         self.assertEquals(close_date, close)
예제 #2
0
 def test_get_close_date(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         notices = categorize_notices(get_notices_by_regid(regid))
         notice = notices[9]
         close_date = get_close_date(notice)
         close = timezone.get_current_timezone().localize(
             datetime(2013, 2, 28, 0, 0, 0)).astimezone(pytz.utc)
         self.assertEquals(close_date, close)
예제 #3
0
 def test_get_open_date(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         notices = categorize_notices(get_notices_by_regid(regid))
         notice = notices[9]
         self.assertTrue(notice.is_critical)
         open_date = get_open_date(notice)
         open = timezone.get_current_timezone().localize(
             datetime(2013, 1, 1, 0, 0, 0)).astimezone(pytz.utc)
         self.assertEquals(open_date, open)
예제 #4
0
 def test_get_open_date(self):
     with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                        RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):
         regid = "9136CCB8F66711D5BE060004AC494FFE"
         notices = categorize_notices(get_notices_by_regid(regid))
         notice = notices[9]
         self.assertTrue(notice.is_critical)
         open_date = get_open_date(notice)
         open = timezone.get_current_timezone().localize(
             datetime(2013, 1, 1, 0, 0, 0)).astimezone(pytz.utc)
         self.assertEquals(open_date, open)
예제 #5
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)
예제 #6
0
    def test_categorize_notices(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            notices = categorize_notices(get_notices_by_regid(regid))
            self.assertEquals(len(notices), 23)
            notice = notices[10]
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags,
                              ['tuition_aid_prioritydate_title'])
            self.assertFalse(notice.is_critical)
예제 #7
0
    def test_is_before_bof_days_before_close(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            notices = categorize_notices(get_notices_by_regid(regid))
            notice = notices[9]
            now = timezone.get_current_timezone().localize(
                datetime(2013, 2, 14, 0, 0, 0)).astimezone(pytz.utc)
            self.assertFalse(is_before_bof_days_before_close(now, notice, 14))
            now = timezone.get_current_timezone().localize(
                datetime(2013, 2, 13, 0, 0, 0)).astimezone(pytz.utc)
            self.assertTrue(is_before_bof_days_before_close(now, notice, 14))
예제 #8
0
    def test_categorize_notices(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            notices = categorize_notices(get_notices_by_regid(regid))
            self.assertEquals(len(notices), 23)
            notice = notices[10]
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags,
                              ['tuition_aid_prioritydate_title'])
            self.assertFalse(notice.is_critical)
예제 #9
0
    def test_is_before_bof_days_before_close(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"
            notices = categorize_notices(get_notices_by_regid(regid))
            notice = notices[9]
            now = timezone.get_current_timezone().localize(
                datetime(2013, 2, 14, 0, 0, 0)).astimezone(pytz.utc)
            self.assertFalse(is_before_bof_days_before_close(now, notice, 14))
            now = timezone.get_current_timezone().localize(
                datetime(2013, 2, 13, 0, 0, 0)).astimezone(pytz.utc)
            self.assertTrue(is_before_bof_days_before_close(now, notice, 14))
예제 #10
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)
예제 #11
0
파일: notice.py 프로젝트: kroberts-uw/myuw
def _get_notices_by_regid(user_regid):
    """
    returns SWS notices for a given regid with
    myuw specific categories
    """

    if user_regid is None:
        return None

    timer = Timer()

    try:
        notices = get_notices_by_regid(user_regid)
        if notices is None:
            return None
        return categorize_notices(notices)
    finally:
        log_resp_time(logger,
                      'Notice.get_notices',
                      timer)
예제 #12
0
    def test_map_notice_category(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            notices = get_notices_by_regid(regid)
            self.assertEquals(len(notices), 28)

            notice = map_notice_category(notices[0])
            self.assertEquals(notice.custom_category, "Holds")
            self.assertEquals(notice.location_tags,
                              ['notices_holds', 'reg_card_holds'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[4])
            self.assertEquals(notice.custom_category, "Registration")
            self.assertEquals(notice.location_tags, ['reg_card_messages'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[9])
            self.assertEquals(notice.custom_category, "Admission")
            self.assertEquals(notice.location_tags, ['checklist_feespaid'])
            self.assertFalse(notice.is_critical)

            notice = map_notice_category(notices[11])
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags, ['tuition_direct_deposit'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[14])
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags,
                              ['tuition_aid_prioritydate_title'])
            self.assertFalse(notice.is_critical)

            notice = map_notice_category(notices[20])
            self.assertEquals(
                notice.location_tags,
                ['tuition_summeraid_avail_title', 'reg_summeraid_avail_title'])
            self.assertFalse(notice.is_critical)
예제 #13
0
    def test_map_notice_category(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=FDAO_SWS,
                           RESTCLIENTS_PWS_DAO_CLASS=FDAO_PWS):

            regid = "9136CCB8F66711D5BE060004AC494FFE"

            notices = get_notices_by_regid(regid)
            self.assertEquals(len(notices), 28)

            notice = map_notice_category(notices[0])
            self.assertEquals(notice.custom_category, "Holds")
            self.assertEquals(notice.location_tags, ['notices_holds',
                                                     'reg_card_holds'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[4])
            self.assertEquals(notice.custom_category, "Registration")
            self.assertEquals(notice.location_tags, ['reg_card_messages'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[9])
            self.assertEquals(notice.custom_category, "Admission")
            self.assertEquals(notice.location_tags, ['checklist_feespaid'])
            self.assertFalse(notice.is_critical)

            notice = map_notice_category(notices[11])
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags, ['tuition_direct_deposit'])
            self.assertTrue(notice.is_critical)

            notice = map_notice_category(notices[14])
            self.assertEquals(notice.custom_category, "Fees & Finances")
            self.assertEquals(notice.location_tags,
                              ['tuition_aid_prioritydate_title'])
            self.assertFalse(notice.is_critical)

            notice = map_notice_category(notices[20])
            self.assertEquals(notice.location_tags,
                              ['tuition_summeraid_avail_title',
                               'reg_summeraid_avail_title'])
            self.assertFalse(notice.is_critical)
예제 #14
0
파일: notice.py 프로젝트: fanglinfang/myuw
def _get_notices_by_regid(user_regid):
    """
    returns SWS notices for a given regid with
    myuw specific categories
    """

    if user_regid is None:
        return None

    timer = Timer()

    try:
        notices = get_notices_by_regid(user_regid)
        if notices is not None:
            return categorize_notices(notices)
    except Exception:
        log_exception(logger,
                      'Notice.get_notices',
                      traceback.format_exc())
    finally:
        log_resp_time(logger,
                      'Notice.get_notices',
                      timer)
    return None
예제 #15
0
    def test_notice_resource(self):
        with self.settings(RESTCLIENTS_SWS_DAO_CLASS=
                           'restclients.dao_implementation.sws.File',
                           RESTCLIENTS_PWS_DAO_CLASS=
                           'restclients.dao_implementation.pws.File'):

            notices = get_notices_by_regid("9136CCB8F66711D5BE060004AC494FFE")
            self.assertEquals(len(notices), 17)

            today = date.today()
            yesterday = today - timedelta(days=1)
            tomorrow = today + timedelta(days=1)
            week = today + timedelta(days=2)
            next_week = today + timedelta(weeks=1)
            future = today + timedelta(weeks=3)
            future_end = today + timedelta(weeks=5)

            notice = notices[0]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "IntlStuCheckIn")
            attribute = notice.attributes[1]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              yesterday.strftime("%Y-%m-%d"))

            notice = notices[1]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "QtrBegin")
            self.assertEquals(notice.notice_content,
                              "Summer quarter begins <b>June 23, 2014</b>")

            #Date Attribute
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              future_end.strftime("%Y-%m-%d"))

            #String Attribute
            attribute = notice.attributes[3]
            self.assertEquals(attribute.name, "Quarter")
            self.assertEquals(attribute.data_type, "string")
            self.assertEquals(attribute.get_value(), "Summer")

            #URL Attribute
            attribute = notice.attributes[4]
            self.assertEquals(attribute.name, "Link")
            self.assertEquals(attribute.data_type, "url")
            self.assertEquals(attribute.get_value(), "http://www.uw.edu")

            #Ensure unknown attributes aren't included
            self.assertEquals(len(notice.attributes), 5)

            #Default custom category
            self.assertEquals(notice.custom_category, "Uncategorized")

            notice = notices[2]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "EstPd1RegDate")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              next_week.strftime("%Y-%m-%d"))

            notice = notices[3]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[4]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[4]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[5]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "IntlStuCheckIn")
            self.assertEquals(len(notice.attributes), 0)

            notice = notices[7]
            self.assertEquals(notice.notice_category, "StudentGEN")
            self.assertEquals(notice.notice_type, "AcctBalance")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              next_week.strftime("%Y-%m-%d"))

            notice = notices[8]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "TuitDue")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              next_week.strftime("%Y-%m-%d"))

            notice = notices[12]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "QtrEnd")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(),
                              future_end.strftime("%Y-%m-%d"))

            notice = notices[13]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "DirectDeposit")

            notice = notices[14]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "DirectDepositShort")
            self.assertEquals(notice.long_notice.notice_type, "DirectDeposit")

            notice = notices[15]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "AidPriorityDate")

            notice = notices[16]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "AidPriorityDateShort")
            self.assertEquals(notice.long_notice.notice_type,
                              "AidPriorityDate")
예제 #16
0
    def test_notice_resource(self):
        with self.settings(
            RESTCLIENTS_SWS_DAO_CLASS='restclients.dao_implementation.sws.File',
            RESTCLIENTS_PWS_DAO_CLASS='restclients.dao_implementation.pws.File'):

            notices = get_notices_by_regid("9136CCB8F66711D5BE060004AC494FFE")
            self.assertEquals(len(notices), 17)

            today = date.today()
            yesterday = today - timedelta(days=1)
            tomorrow = today + timedelta(days=1)
            week = today + timedelta(days=2)
            next_week = today + timedelta(weeks=1)
            future = today + timedelta(weeks=3)
            future_end = today + timedelta(weeks=5)

            notice = notices[0]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "IntlStuCheckIn")
            attribute = notice.attributes[1]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), yesterday.strftime("%Y-%m-%d"))


            notice = notices[1]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "QtrBegin")
            self.assertEquals(notice.notice_content,
                              "Summer quarter begins <b>June 23, 2014</b>")

            #Date Attribute
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), future_end.strftime("%Y-%m-%d"))

            #String Attribute
            attribute = notice.attributes[3]
            self.assertEquals(attribute.name, "Quarter")
            self.assertEquals(attribute.data_type, "string")
            self.assertEquals(attribute.get_value(), "Summer")

            #URL Attribute
            attribute = notice.attributes[4]
            self.assertEquals(attribute.name, "Link")
            self.assertEquals(attribute.data_type, "url")
            self.assertEquals(attribute.get_value(), "http://www.uw.edu")

            #Ensure unknown attributes aren't included
            self.assertEquals(len(notice.attributes), 5)

            #Default custom category
            self.assertEquals(notice.custom_category, "Uncategorized")


            notice = notices[2]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "EstPd1RegDate")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), next_week.strftime("%Y-%m-%d"))

            notice = notices[3]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[4]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[4]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "PreRegNow")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), week.strftime("%Y-%m-%d"))

            notice = notices[5]
            self.assertEquals(notice.notice_category, "StudentALR")
            self.assertEquals(notice.notice_type, "IntlStuCheckIn")
            self.assertEquals(len(notice.attributes), 0)

            notice = notices[7]
            self.assertEquals(notice.notice_category, "StudentGEN")
            self.assertEquals(notice.notice_type, "AcctBalance")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), next_week.strftime("%Y-%m-%d"))

            notice = notices[8]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "TuitDue")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), next_week.strftime("%Y-%m-%d"))

            notice = notices[12]
            self.assertEquals(notice.notice_category, "StudentDAD")
            self.assertEquals(notice.notice_type, "QtrEnd")
            attribute = notice.attributes[0]
            self.assertEquals(attribute.name, "Date")
            self.assertEquals(attribute.data_type, "date")
            self.assertEquals(attribute.get_value(), future_end.strftime("%Y-%m-%d"))

            notice = notices[13]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "DirectDeposit")

            notice = notices[14]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "DirectDepositShort")
            self.assertEquals(notice.long_notice.notice_type, "DirectDeposit")

            notice = notices[15]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "AidPriorityDate")

            notice = notices[16]
            self.assertEquals(notice.notice_category, "StudentFinAid")
            self.assertEquals(notice.notice_type, "AidPriorityDateShort")
            self.assertEquals(notice.long_notice.notice_type, "AidPriorityDate")