예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
def test_daily_accrued_interest(self):
    bank = Bank()
    checkingAccount = createBankAccount(CHECKING)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))

    two_years_ago = datetime.datetime.today() - datetime.timedelta(days=730)
    checkingAccount.deposit(1000.0, transactionDate=two_years_ago)
    assert_equals(checkingAccount.interestEarned(), 2.0)

    checkingAccount.deposit(1000.0, transactionDate=ONE_YEAR_AGO)
    assert_almost_equals(checkingAccount.interestEarned(), 3.0, places=2)

    half_year_ago = datetime.datetime.today() - datetime.timedelta(days=182)
    checkingAccount.deposit(1000.0, transactionDate=half_year_ago)
    assert_almost_equals(checkingAccount.interestEarned(), 3.5, places=2)
예제 #4
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)")
예제 #5
0
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(), 51.0)
예제 #6
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)")
예제 #7
0
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)
예제 #8
0
def test_savings_account(self):
    bank = Bank()
    checkingAccount = createBankAccount(SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))
    checkingAccount.deposit(1500.0, ONE_YEAR_AGO)
    assert_equals(bank.totalInterestPaid(), 2.0)
예제 #9
0

@nottest
def test_threeAccounts():
    oscar = Customer("Oscar").openAccount(Account(SAVINGS))
    oscar.openAccount(Account(CHECKING))
    assert_equals(oscar.numAccs(), 3)


bank = Bank()
checkingAccount = Account(CHECKING)
savingAccount = Account(SAVINGS)
bill = Customer("Bill")
bill.openAccount(checkingAccount)
bill.openAccount(savingAccount)
bank.addCustomer(bill)
checkingAccount.deposit(100.0)
checkingAccount.deposit(500.0)
checkingAccount.deposit(2000.0)
savingAccount.deposit(900.0)

from_acc = checkingAccount
to_acc = savingAccount


def test_transfer_success():
    transfer_amount = 100
    result = bill.transfer(from_acc, to_acc, transfer_amount)
    assert_equals(result, True)
    assert_equals(checkingAccount.sumTransactions(), 2500.0)
    assert_equals(savingAccount.sumTransactions(), 1000.0)