예제 #1
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
예제 #2
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
예제 #3
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)
예제 #4
0
def withdraw_negative_amount(): #this tests if the user is trying to withdraw a negative amount
    newUser = BankUser("Nishu")
    newUser.addAccount(AccountType.SAVINGS)
    newUser.deposit(AccountType.SAVINGS, 1000)

    try:
        newUser.withdraw(AccountType.SAVINGS, -100)
    except Exception as excep:
        print(excep)
예제 #5
0
def test_get_balance(): #this tests if the user is trying to get a balance for a nonexistent account
    newUser = BankUser("Nishu")
    newUser.addAccount(AccountType.CHECKING)
    newUser.deposit(AccountType.CHECKING, 1000)

    try:
        newUser.getBalance(AccountType.SAVINGS)
    except Exception as excep:
        print(excep)
예제 #6
0
def test_over_withdrawal():  #this test function should throw an
    user = BankUser("Joe")
    user.addAccount(AccountType.SAVINGS)
    user.deposit(AccountType.SAVINGS, 10)
    try:
        user.withdraw(AccountType.SAVINGS,
                      1000)  #this should throw an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
예제 #7
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)
예제 #8
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)
예제 #9
0
def test_duplicate_account(): #this tests if the accounta already exists
    newUser = BankUser("Nishu")
    newUser.addAccount(AccountType.CHECKING)

    try:
        newUser.addAccount(AccountType.CHECKING)
    except Exception as excep:
        print(excep)
예제 #10
0
def test_create_same_checking_account():  #this test function should throw an
    user = BankUser("Joe")
    user.addAccount(AccountType.CHECKING)
    try:
        user.addAccount(
            AccountType.CHECKING)  #this should throw an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
예제 #11
0
def test_deposit_wrong_account():  #this test function should throw an
    user = BankUser("Joe")
    user.addAccount(AccountType.SAVINGS)
    try:
        user.deposit(AccountType.CHECKING,
                     100)  #this should throw an Exception or Error
    except Exception as e:
        print(e)  #print the message for the Exeption
예제 #12
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)
예제 #13
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
예제 #14
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
예제 #15
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
예제 #16
0
def test_withdraw_noAccount():
    user = BankUser("Joe")
    try:
        user.withdraw(AccountType.CHECKING, 10)
    except Exception as e:
        print(e)
예제 #17
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
예제 #18
0
def test_getBalance_noAccount():
    user = BankUser("Joe")
    try:
        user.getBalance(AccountType.CHECKING)
    except Exception as e:
        print(e)
예제 #19
0
def test_deposit_noAccount():
    user = BankUser("Joe")
    try:
        user.getBalance(AccountType.SAVINGS)
    except Exception as e:
        print(e)
def test_over_withdrawal(): #this test function should throw an Exception or Error 
    user = BankUser("Joe");
    user.addAccount(AccountType.SAVINGS);
    user.deposit(AccountType.SAVINGS, 10);
    user.withdraw(AccountType.SAVINGS, 1);
    print(user.getBalance(AccountType.SAVINGS));
    print(user);

    
    #CHECK WITHDRAWAL LARGER THAN BALANCE
    try:
        user.withdraw(AccountType.SAVINGS, 1000); #this will cause an Exception or Error
    except Exception as e:
        print(e); #print the message for the Exeption

    #CHECK NEGATIVE WITHDRAWAL 
    try:
        user.withdraw(AccountType.SAVINGS, -10); #this will cause an Exception or Error
    except Exception as e:
        print(e); #print the message for the Exeption

    #CHECK NEGATIVE DEPOSIT 
    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

    #CHECK ACCOUNT TYPE WORKS FOR GETBALACE
    try:
        user.getBalance(AccountType.CHECKING); #this will cause an Exception or Error
    except Exception as e:
        print(e); #print the message for the Exeption

    #CHECK ACCOUNT TYPE WORKS FOR DEPOSIT
    try:
        user.deposit(AccountType.CHECKING,1); #this will cause an Exception or Error
    except Exception as e:
        print(e); #print the message for the Exeption

    #CHECK ACCOUNT TYPE WORKS FOR WITHDRAWAL
    try:
        user.withdraw(AccountType.CHECKING,1); #this will cause an Exception or Error
    except Exception as e:
        print(e); #print the message for the Exeption
def test_over_withdrawal(
):  #this test function should throw an Exception or Error
    user = BankUser("Joe")
    user.addAccount(AccountType.SAVINGS)
    user.deposit(AccountType.SAVINGS, 10)

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

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

    ## test withdraw wrong account
    try:
        user.withdraw(AccountType.CHECKING, 8)
    except Exception as e:
        print(e)

    ## test withdraw negative amount
    try:
        user.withdraw(AccountType.SAVINGS, -10)
    except Exception as e:
        print(e)

    ## test deposit negative amount
    try:
        user.deposit(AccountType.SAVINGS, -10)
    except Exception as e:
        print(e)

    ## test deposit to wrong account
    try:
        user.deposit(AccountType.CHECKING, 100)
    except Exception as e:
        print(e)

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

    ### test valid functions ###
    user.deposit(AccountType.SAVINGS, 100)
    user.withdraw(AccountType.SAVINGS, 10)
    print(user.getBalance(AccountType.SAVINGS))
    user.addAccount(AccountType.CHECKING)
    user.deposit(AccountType.CHECKING, 500)
    print(user.getBalance(AccountType.CHECKING))

    print(user)
    print(str(user))
    print(str(user.accounts[AccountType.SAVINGS.name]))
    print(str(user.accounts[AccountType.CHECKING.name]))
예제 #22
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]))