Example #1
0
def get_account_balances_by_uwnetid(uwnetid):
    """
    returns restclients.models.hfs.HfsAccouts
    for the given uwnetid
    """
    if uwnetid is None:
        return None
    return get_hfs_accounts(uwnetid)
Example #2
0
    def test_get_hfs_empty_account(self):
        with self.settings(RESTCLIENTS_HFS_DAO_CLASS=
                           'restclients.dao_implementation.hfs.File'):

            hfs_acc = get_hfs_accounts("eight")
            self.assertIsNotNone(hfs_acc.student_husky_card)
            self.assertIsNone(hfs_acc.employee_husky_card)
            self.assertIsNotNone(hfs_acc.resident_dining)
Example #3
0
def get_account_balances_by_uwnetid(uwnetid):
    """
    returns restclients.models.hfs.HfsAccouts
    for the given uwnetid
    """
    if uwnetid is None:
        return None
    return get_hfs_accounts(uwnetid)
Example #4
0
    def test_invalid_user(self):
        with self.settings(RESTCLIENTS_HFS_DAO_CLASS=
                           'restclients.dao_implementation.hfs.File'):

            #Testing error message in a 200 response
            self.assertRaises(DataFailureException, get_hfs_accounts,
                              "invalidnetid")
            self.assertRaises(DataFailureException, get_hfs_accounts,
                              "invalidnetid123")

            try:
                get_hfs_accounts("jerror")
            except DataFailureException as ex:
                self.assertEquals(ex.status, 500)
                self.assertEquals(ex.msg, "An error has occurred.")
            try:
                get_hfs_accounts("none")
            except DataFailureException as ex:
                self.assertEquals(ex.status, 404)
                self.assertEquals(
                    ex.msg, "UWNetID none not found in IDCard Database.")

            MSG = "%s%s%s" % (
                "Input for this method must be either a valid UWNetID ",
                "or two nine-digit Student and ",
                "Faculty/Staff/Employee ID numbers, comma-separated.")
            try:
                get_hfs_accounts("invalidnetid")
            except DataFailureException as ex:
                self.assertEquals(ex.status, 400)
                self.assertEquals(ex.msg, MSG)
Example #5
0
    def test_invalid_user(self):
        #Testing error message in a 200 response
        self.assertRaises(DataFailureException,
                          get_hfs_accounts, "invalidnetid")
        self.assertRaises(DataFailureException,
                          get_hfs_accounts, "invalidnetid123")

        try:
            get_hfs_accounts("jerror")
        except DataFailureException as ex:
            self.assertEquals(ex.status, 500)
            self.assertEquals(ex.msg,
                              "An error has occurred.")
        try:
            get_hfs_accounts("none")
        except DataFailureException as ex:
            self.assertEquals(ex.status, 404)
            self.assertEquals(ex.msg,
                              "UWNetID none not found in IDCard Database.")

        MSG = "%s%s%s" % (
            "Input for this method must be either a valid UWNetID ",
            "or two nine-digit Student and ",
            "Faculty/Staff/Employee ID numbers, comma-separated.")
        try:
            get_hfs_accounts("invalidnetid")
        except DataFailureException as ex:
            self.assertEquals(ex.status, 400)
            self.assertEquals(
                ex.msg, MSG)
Example #6
0
    def test_get_hfs_partially_empty_account(self):
        hfs_acc = get_hfs_accounts("jnew")
        self.assertIsNotNone(hfs_acc.student_husky_card)
        self.assertIsNone(hfs_acc.student_husky_card.last_updated)
        self.assertEquals(hfs_acc.student_husky_card.balance,
                          Decimal('0.0'))

        self.assertIsNone(hfs_acc.employee_husky_card)

        self.assertEquals(hfs_acc.resident_dining.balance,
                          Decimal('777.89'))
        self.assertEquals(hfs_acc.resident_dining.last_updated,
                           datetime(2014, 5, 17, 13, 15, 36))
        self.assertEquals(hfs_acc.resident_dining.add_funds_url,
                          ADD_FUND_URL)
Example #7
0
def get_account_balances_by_uwnetid(uwnetid):
    """
    returns restclients.models.hfs.HfsAccouts
    for the given uwnetid
    """
    if uwnetid is None:
        return None
    id = "%s %s" % ('get_hfs_accounts', uwnetid)

    try:
        return get_hfs_accounts(uwnetid)
    except Exception as ex:
        log_exception(logger,
                      id,
                      traceback.format_exc())
    return None
Example #8
0
    def test_get_hfs_partially_empty_account(self):
        with self.settings(RESTCLIENTS_HFS_DAO_CLASS=
                           'restclients.dao_implementation.hfs.File'):

            hfs_acc = get_hfs_accounts("jnew")
            self.assertIsNotNone(hfs_acc.student_husky_card)
            self.assertIsNone(hfs_acc.student_husky_card.last_updated)
            self.assertEquals(hfs_acc.student_husky_card.balance,
                              Decimal('0.0'))

            self.assertIsNone(hfs_acc.employee_husky_card)

            self.assertEquals(hfs_acc.resident_dining.balance,
                              Decimal('777.89'))
            self.assertEquals(hfs_acc.resident_dining.last_updated,
                              datetime(2014, 5, 17, 13, 15, 36))
            self.assertEquals(hfs_acc.resident_dining.add_funds_url,
                              ADD_FUND_URL)
Example #9
0
    def test_get_hfs_accounts(self):
        hfs_acc = get_hfs_accounts("javerage")
        self.assertEquals(hfs_acc.student_husky_card.last_updated,
                          datetime(2014, 6, 2, 15, 17, 16))
        self.assertEquals(hfs_acc.student_husky_card.balance,
                          Decimal('1.23'))
        self.assertEquals(
            hfs_acc.student_husky_card.add_funds_url,
            ADD_FUND_URL)

        self.assertEquals(hfs_acc.employee_husky_card.last_updated,
                          datetime(2014, 5, 19, 14, 16, 26))
        self.assertEquals(hfs_acc.employee_husky_card.balance,
                          Decimal('0.56'))
        self.assertEquals(hfs_acc.employee_husky_card.add_funds_url,
                          ADD_FUND_URL)

        self.assertEquals(hfs_acc.resident_dining.last_updated,
                          datetime(2014, 6, 1, 13, 15, 36))
        self.assertEquals(hfs_acc.resident_dining.balance, Decimal('7.89'))
        self.assertEquals(hfs_acc.resident_dining.add_funds_url,
                          ADD_FUND_URL)
Example #10
0
    def test_get_hfs_accounts(self):
        with self.settings(RESTCLIENTS_HFS_DAO_CLASS=
                           'restclients.dao_implementation.hfs.File'):

            hfs_acc = get_hfs_accounts("javerage")
            self.assertEquals(hfs_acc.student_husky_card.last_updated,
                              datetime(2014, 6, 2, 15, 17, 16))
            self.assertEquals(hfs_acc.student_husky_card.balance,
                              Decimal('1.23'))
            self.assertEquals(hfs_acc.student_husky_card.add_funds_url,
                              ADD_FUND_URL)

            self.assertEquals(hfs_acc.employee_husky_card.last_updated,
                              datetime(2014, 5, 19, 14, 16, 26))
            self.assertEquals(hfs_acc.employee_husky_card.balance,
                              Decimal('0.56'))
            self.assertEquals(hfs_acc.employee_husky_card.add_funds_url,
                              ADD_FUND_URL)

            self.assertEquals(hfs_acc.resident_dining.last_updated,
                              datetime(2014, 6, 1, 13, 15, 36))
            self.assertEquals(hfs_acc.resident_dining.balance, Decimal('7.89'))
            self.assertEquals(hfs_acc.resident_dining.add_funds_url,
                              ADD_FUND_URL)
Example #11
0
 def test_float_parsing(self):
     with self.settings(RESTCLIENTS_HFS_DAO_CLASS=
                        'restclients.dao_implementation.hfs.File'):
         hfs_acc = get_hfs_accounts("jbothell")
         self.assertEquals(hfs_acc.student_husky_card.balance,
                           Decimal('5.1'))
Example #12
0
 def test_float_parsing(self):
     hfs_acc = get_hfs_accounts("jbothell")
     self.assertEquals(hfs_acc.student_husky_card.balance,
                       Decimal('5.1'))
Example #13
0
 def test_get_hfs_empty_account(self):
     hfs_acc = get_hfs_accounts("eight")
     self.assertIsNotNone(hfs_acc.student_husky_card)
     self.assertIsNone(hfs_acc.employee_husky_card)
     self.assertIsNotNone(hfs_acc.resident_dining)