def test_checking_account(): bank = Bank() checkingAccount = CheckingAcc() bill = Customer("Bill").openAccount(checkingAccount) bank.addCustomer(bill) checkingAccount.deposit(100.0) assert_equals(bank.totalYearlyInterest(), 0.1)
def test_unique_customer_added(): bank = Bank() john1 = Customer("John") bank.addCustomer(john1) bank.addCustomer(john1) assert_equals(bank.customerSummary(), "Customer Summary\n - John (0 accounts)")
def test_checking_account(): bank = Bank() checkingAccount = Account(CHECKING) bill = Customer("Bill").openAccount(checkingAccount) bank.addCustomer(bill) checkingAccount.deposit(100.0) assert_equals(bank.totalInterestPaid(), 0.1)
def test_checking_account(): bank = Bank() checkingAccount = Account(CHECKING) bill = Customer("Bill").openAccount(checkingAccount) bank.addCustomer(bill) checkingAccount.deposit(100.0) assert_equals(bank.totalInterestPaid(), 0.1 * DateProvider.getTotalDaysPassedRatio())
def test_maxi_savings_account(): bank = Bank() maxiSavingsAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) maxiSavingsAccount.deposit(3000.0) assert_equals(maxiSavingsAccount.checkTransactionInLastTenDays(), True) assert_equals(3000 * 0.001 * DateProvider.getTotalDaysPassedRatio(), maxiSavingsAccount.interestEarned())
def test_maxi_savings_account(): bank = Bank() maxiAccount = MaxiSavingsAcc() bank.addCustomer(Customer("Bill").openAccount(maxiAccount)) maxiAccount.deposit(3100.0) maxiAccount.withdraw(100.0) assert_true(bank.totalYearlyInterest() < 150.0)
def test_maxi_savings_account(): bank = Bank() checkingAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) year_behind = datetime.datetime.now() - datetime.timedelta(365) checkingAccount.deposit(3000.0, year_behind) assert_equals(bank.totalInterestPaid(), 150.0)
def test_checking_account(): bank = Bank() checkingAccount = Account(CHECKING) bill = Customer("Bill").openAccount(checkingAccount) bank.addCustomer(bill) year_behind = datetime.datetime.now() - datetime.timedelta(365) checkingAccount.deposit(100.0, year_behind) assert_equals(bank.totalInterestPaid(), 0.1)
def test_maxi_savings_account_with_withdrawals(): bank = Bank() checkingAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) year_behind = datetime.datetime.now() - datetime.timedelta(365) five_days_behind = datetime.datetime.now() - datetime.timedelta(5) checkingAccount.deposit(3000.0, year_behind) checkingAccount.withdraw(1000.0, five_days_behind) assert_almost_equals(bank.totalInterestPaid(), 147.97, places=2)
def test_check_transaction_in_last_10_days(): bank = Bank() maxiSavingsAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) maxiSavingsAccount.deposit(3000.0) assert_equals(maxiSavingsAccount.transactions[0].amount, 3000) assert_equals(maxiSavingsAccount.transactions[0].transactionDate.year, DateProvider.now().year) assert_equals(maxiSavingsAccount.transactions[0].transactionDate.month, DateProvider.now().month) assert_equals(maxiSavingsAccount.transactions[0].transactionDate.day, DateProvider.now().day) assert_equals(maxiSavingsAccount.transactions[0].transactionDate >= DateProvider.tenDaysAgo(), True) assert_equals(maxiSavingsAccount.checkTransactionInLastTenDays(), True)
def test_checking_account(): bank = Bank() bill = bank.addCustomer("Bill") bill_new_checking = bill.openAccount('CHECKING') bill_new_checking.deposit(100.00) bill_new_checking.account_age_in_days = 20 assert_equals(round(bank.totalInterestPaid(),3), .005)
def test_savings_account(): bank = Bank() bill = bank.addCustomer("Bill") bill_new_maxi = bill.openAccount('MAXI_SAVINGS') bill_new_maxi.deposit(1500.0) bill_new_maxi.account_age_in_days = 10 assert_equals(round(bill_new_maxi.interestEarnedDaily(),2),1.9)
def test_threeAccounts(): bank = Bank() oscar = bank.addCustomer("Oscar") oscar_savings = oscar.openAccount('SAVINGS') oscar_checking = oscar.openAccount('CHECKING') oscar_checking = oscar.openAccount('MAXI_SAVINGS') assert_equals(oscar.numAccs(), 3)
def test_transfer(): bank = Bank() bill = bank.addCustomer("Bill") bill_savings = bill.openAccount('SAVINGS') bill_checking = bill.openAccount('CHECKING') bill_savings.deposit(200.0) bill_checking.deposit(100.0) bill.makeTransfer(50.0,bill_savings,bill_checking) assert_equals(bill_checking.balance,50.0) assert_equals(bill_savings.balance,250.0)
def test_statement(): bank = Bank() henry = bank.addCustomer("Henry") henry_checking=henry.openAccount('CHECKING') henry_savings = henry.openAccount('SAVINGS') henry_checkings.deposit(100.0) henry_savings.deposit(4000.0) henry_savings.withdraw(200.0) assert_equals(henry.getStatement(), "Statement for Henry" + "\n\nChecking Account\n deposit $100.00\nTotal $100.00" + "\n\nSavings Account\n deposit $4000.00\n withdrawal $200.00\nTotal $3800.00" + "\n\nTotal In All Accounts $3900.00")
class TestBank: def setUp(self): self.bank = Bank() def tearDown(self): pass def test_customer_summary(self): john = Customer("John").openAccount(SavingsAc()) self.bank.addCustomer(john) assert_equals(self.bank.customerSummary(), "Customer Summary\n - John (1 account)") def test_checking_account(self): checkingAccount = CheckingAc() bill = Customer("Bill").openAccount(checkingAccount) self.bank.addCustomer(bill) txnDate = datetime.strptime('May 1 2016 10:14AM', '%b %d %Y %I:%M%p') checkingAccount.deposit(100.0, txnDate) txnDate = datetime.strptime('May 5 2016 3:21PM', '%b %d %Y %I:%M%p') checkingAccount.deposit(200.0, txnDate) #since we moved over to daily interest and the total interest # is calculated on a daily basis, this result will change # assert_equals(self.bank.totalInterestPaid(), 0.1) assert_equals(self.bank.totalInterestPaid(), 0.00410958904109589) def test_savings_account(self): savingsAccount = SavingsAc() self.bank.addCustomer(Customer("Bill").openAccount(savingsAccount)) txnDate = datetime.strptime('May 1 2012 10:14AM', '%b %d %Y %I:%M%p') savingsAccount.deposit(100.0, txnDate) assert_equals(self.bank.totalInterestPaid(), 0.40273972602739727) def test_maxi_savings_account(self): maxiSavingsAccount = MaxiSavingsAc() self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) txnDate = datetime.strptime('Feb 5 2012 4:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.deposit(3000.0,txnDate) # Different interest after maxi interst calculation logic is changed # assert_equals(self.bank.totalInterestPaid(), 170.0) assert_equals(self.bank.totalInterestPaid(), 639.4520547945206) def test_maxi_savings_account_recent_withdrawal(self): maxiSavingsAccount = MaxiSavingsAc() self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) txnDate = datetime.strptime('Feb 5 2012 3:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.deposit(200.0, txnDate) txnDate = datetime.strptime('Feb 5 2012 4:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.deposit(3000.0, txnDate) # Putting a date in the future, which should fail elsewhere in the ideal # scenario, but this is to ensure that this test case passes for a longtime txnDate = datetime.strptime('May 9 2016 3:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.withdraw(100.0, txnDate) assert_equals(self.bank.totalInterestPaid(), 0.008493150684931507) def test_maxi_savings_account_nonrecent_withdrawal(self): maxiSavingsAccount = MaxiSavingsAc() self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) txnDate = datetime.strptime('Feb 5 2012 3:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.deposit(200.0, txnDate) txnDate = datetime.strptime('Feb 5 2012 4:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.deposit(3000.0, txnDate) txnDate = datetime.strptime('Mar 19 2012 3:21PM', '%b %d %Y %I:%M%p') maxiSavingsAccount.withdraw(100.0, txnDate) assert_equals(self.bank.totalInterestPaid(), 642.5068493150685)
def test_maxi_savings_account(): bank = Bank() maxiSavingsAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount)) maxiSavingsAccount.deposit(3000.0) assert_equals(bank.totalInterestPaid(), maxiSavingsAccount.interestEarned())
def test_savings_account(): bank = Bank() savingsAccount = Account(SAVINGS) bank.addCustomer(Customer("Bill").openAccount(savingsAccount)) savingsAccount.deposit(1500.0) assert_equals(bank.totalInterestPaid(), savingsAccount.interestEarned())
def test_maxi_savings_account(): bank = Bank() checkingAccount = Account(MAXI_SAVINGS) bank.addCustomer(Customer("Bill").openAccount(checkingAccount)) checkingAccount.deposit(3000.0) assert_equals(bank.totalInterestPaid(), 170.0)
def test_savings_account(): bank = Bank() savingsAccount = SavingsAcc() bank.addCustomer(Customer("Bill").openAccount(savingsAccount)) savingsAccount.deposit(1500.0) assert_equals(bank.totalYearlyInterest(), 2.0)
def test_customer_summary(): bank = Bank() john = bank.addCustomer('John') john_new_checking = john.openAccount('CHECKING') assert_equals(bank.customerSummary(),"Customer Summary\n - John (1 account)")
def test_maxi_savings_account(): bank = Bank() bill = bank.addCustomer("Bill") bill_new_maxi = bill.openAccount('MAXI_SAVINGS') bill_new_maxi.deposit(3000.0)
def test_maxi_savings_account(): bank = Bank() maxiAccount = MaxiSavingsAcc() bank.addCustomer(Customer("Bill").openAccount(maxiAccount)) maxiAccount.deposit(3000.0) assert_equals(bank.totalYearlyInterest(), 150.0)
def test_customer_summary(): bank = Bank() john = Customer("John").openAccount(Account(CHECKING)) bank.addCustomer(john) assert_equals(bank.customerSummary(), "Customer Summary\n - John (1 account)")
def test_oneAccount(): bank = Bank() oscar = bank.addCustomer("Oscar") oscar_savings = oscar.openAccount('SAVINGS') assert_equals(oscar.numAccs(), 1)