def test_transferAmount(): checkingAccount = Account(CHECKING) savingsAccount = Account(SAVINGS) oscar = Customer("Oscar").openAccount(checkingAccount) oscar.openAccount(savingsAccount) checkingAccount.deposit(100.0) transfered = oscar.transfer(checkingAccount, savingsAccount, 10) assert_equals(transfered, True) assert_equals(savingsAccount.amount, 10.)
def test_transferAmountBelowZero(): checkingAccount = Account(CHECKING) savingsAccount = Account(SAVINGS) oscar = Customer("Oscar").openAccount(checkingAccount) oscar.openAccount(savingsAccount) try: oscar.transfer(checkingAccount, savingsAccount, -1) except ValueError as e: result = str(e) assert_equals(result, 'Incorrect amount, should be more than 0')
def test_transferNotEnoughFunds(): checkingAccount = Account(CHECKING) savingsAccount = Account(SAVINGS) oscar = Customer("Oscar").openAccount(checkingAccount) oscar.openAccount(savingsAccount) try: oscar.transfer(savingsAccount, savingsAccount, 10) except ValueError as e: result = str(e) assert_equals(result, 'Incorrect amount, should be more than ' 'source account amount')
def test_transfer(self): checkingAccount = CheckingAc() savingsAccount = SavingsAc() oscar = Customer("Oscar").openAccount(checkingAccount) oscar.openAccount(savingsAccount) checkingAccount.deposit(100.0) savingsAccount.deposit(4000.0) savingsAccount.withdraw(200.0) todayDate = datetime.now() savingsAccount.transfer(500.0, checkingAccount, todayDate) assert_equals(oscar.getStatement(), "Statement for Oscar" + "\n\nChecking Account\n deposit $100.00\n deposit $500.00\nTotal $600.00" + "\n\nSavings Account\n deposit $4000.00\n withdrawal $200.00\n withdrawal $500.00\nTotal $3300.00" + "\n\nTotal In All Accounts $3900.00")
def test_threeAccounts(): oscar = Customer("Oscar").openAccount(Account(SAVINGS)) oscar.openAccount(Account(CHECKING)) oscar.openAccount(Account(MAXI_SAVINGS)) assert_equals(oscar.numAccs(), 3)
def test_threeAccounts(): oscar = Customer("Oscar").openAccount(SavingsAcc()) oscar.openAccount(CheckingAcc()).openAccount(MaxiSavingsAcc()) assert_equals(oscar.numAccs(), 3)
def test_twoAccounts(self): oscar = Customer("Oscar").openAccount(SavingsAc()) oscar.openAccount(CheckingAc()) assert_equals(oscar.numAccs(), 2)