Ejemplo n.º 1
0
 def test_credit_acc_below_zero(self):
     chrgamt = "$2589"
     crdamt = "$2600"
     acc = Account(name="Alan", ccnum="4111111111111111", cclimit="$3000")
     acc.charge_acc(chrgamt)
     acc.credit_acc(crdamt)
     self.assertEqual(acc.balance, -11)
Ejemplo n.º 2
0
def process_input(input, accdict):
    """
    Process all arguments into accounts and add them to the dictionary. Return a dictionary of all active accounts.
    :param input: the command line arguments converted into a list:
    :param accdict: a dictionary containing all active accounts with the account name as a key.
    :return an updated accdict:
    """
    accinfo = input.split()
    if accinfo[1] in accdict:
        acc = accdict[accinfo[1]]
    else:
        acc = None
    if not acc and accinfo[0] == 'Add':
        acc = Account(name=accinfo[1], ccnum=accinfo[2], cclimit=accinfo[3])
    if acc and accinfo[0] == 'Charge':
        acc.charge_acc(accinfo[2])
    if acc and accinfo[0] == 'Credit':
        acc.credit_acc(accinfo[2])
    accdict[acc.name] = acc
    return accdict
Ejemplo n.º 3
0
 def test_credit_acc_decline_invalid_cc_num(self):
     acc = Account(name="Alan", ccnum="1234567890123456", cclimit="$3000")
     self.assertFalse(acc.credit_acc("$59"))