Ejemplo n.º 1
0
def test_deposit_neg():  #this test function should throw an Exception or Error
    user = BankUser("Joe")
    user.addAccount(AccountType.CHECKING)
    try:
        user.deposit(AccountType.CHECKING, -10)
    except Exception as e:
        print(e)
Ejemplo n.º 2
0
def test_over_withdrawal(): #this test function should throw an Exception or Error 
    newUser = BankUser("Nishu")
    newUser.addAccount(AccountType.CHECKING)
    newUser.deposit(AccountType.CHECKING, 500)

    try:
        newUser.withdraw(AccountType.CHECKING, 1000)
    except Exception as excep:
        print(excep)
Ejemplo n.º 3
0
def test_null_account(): #this tests whether or not the account exists
    newUser = BankUser("Nishu")
    newUser.addAccount(AccountType.SAVINGS)
    newUser.deposit(AccountType.SAVINGS, 1000)

    try:
        newUser.deposit(AccountType.CHECKING, 1000)
    except Exception as excep:
        print(excep)
Ejemplo n.º 4
0
def test_over_addAccount_2():  #this test function should work
    user = BankUser("Jacob")
    user.addAccount(AccountType.CHECKING)

    try:
        user.addAccount(AccountType.SAVINGS)
        print("Successfully added account!")
    except Exception as e:
        print(e)
Ejemplo n.º 5
0
def test_over_deposit_2():  #this test function should work
    user = BankUser("Jim")
    user.addAccount(AccountType.SAVINGS)

    try:
        new_balance = user.deposit(AccountType.SAVINGS, 10)
        print("The new_balance is " + str(new_balance))
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 6
0
def test_over_withdrawal_3(
):  #this test function should throw an Exception or Error
    user = BankUser("Joe")
    user.addAccount(AccountType.CHECKING)
    try:
        user.withdraw(AccountType.CHECKING,
                      -10)  #this will cause an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 7
0
def test_over_deposit_1(
):  #this test function should throw an Exception or Error
    user = BankUser("Jack")
    user.addAccount(AccountType.SAVINGS)

    try:
        user.deposit(AccountType.SAVINGS,
                     -10)  #this will cause an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 8
0
def test_over_addAccount_1(
):  #this test function should throw an Exception or Error
    user = BankUser("Jason")
    user.addAccount(AccountType.CHECKING)

    try:
        user.addAccount(
            AccountType.CHECKING)  #this will cause an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 9
0
def test_over__str__():  #this test function should work
    user = BankUser("Jackson")
    user.addAccount(AccountType.CHECKING)
    user.deposit(AccountType.CHECKING, 10)
    user.addAccount(AccountType.SAVINGS)
    user.deposit(AccountType.SAVINGS, 10)
    try:
        print(user)
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 10
0
def test_over_getBalance_():  #this test function should work
    user = BankUser("Javi")
    user.addAccount(AccountType.CHECKING)
    user.deposit(AccountType.CHECKING, 20)
    user.addAccount(AccountType.SAVINGS)
    user.deposit(AccountType.SAVINGS, 1)
    try:
        print(user.getBalance(AccountType.CHECKING))
        print(user.getBalance(AccountType.SAVINGS))
    except Exception as e:
        print(e)  #print the message for the Exeption
Ejemplo n.º 11
0
def test_over_withdrawal():
    user = BankUser("XinZeng")
    user.addAccount(AccountType.SAVINGS)
    user.deposit(AccountType.SAVINGS, 100)

    # test for invalid situation
    # deposit a negative value
    try:
        user.deposit(AccountType.SAVINGS, -1)
    except Exception as e:
        print(e)

    # withdraw more than balance
    try:
        user.withdraw(AccountType.SAVINGS, 200)
    except Exception as e:
        print(e)

    # withdraw a negative value
    try:
        user.withdraw(AccountType.SAVINGS, -1)
    except Exception as e:
        print(e)

    # open multiple saving account
    try:
        user.addAccount(AccountType.SAVINGS)
    except Exception as e:
        print(e)

    # withdraw from a different account
    try:
        user.withdraw(AccountType.CHECKING, 20)
    except Exception as e:
        print(e)

    # deposit to a different account
    try:
        user.deposit(AccountType.CHECKING, 1)
    except Exception as e:
        print(e)

    # get balance from wrong account
    try:
        user.getBalance(AccountType.CHECKING)
    except Exception as e:
        print(e)

    # test for valid situation
    user.withdraw(AccountType.SAVINGS, 50)
    print("Balance:", user.getBalance(AccountType.SAVINGS))
    print(user)
    print(str(user))
    print(str(user.account[AccountType.SAVINGS]))
    user.addAccount(AccountType.CHECKING)
    print("Balance:", user.getBalance(AccountType.CHECKING))
    print(user)
    print(str(user.account[AccountType.CHECKING]))