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]))
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)
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
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
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)
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)
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)
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)
def test_over_withdrawal_2(): #this test function should work user = BankUser("Jeff") user.addAccount(AccountType.SAVINGS) user.deposit(AccountType.SAVINGS, 10) try: new_balance = user.withdraw(AccountType.SAVINGS, 1) print("The new_balance is " + str(new_balance)) except Exception as e: print(e) #print the message for the Exeption
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
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
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
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]))
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