Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)")
Exemplo n.º 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)
Exemplo n.º 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)")
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)