Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 59 additions & 35 deletions tests/customer_tests.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,60 @@
from nose.tools import assert_equals, nottest
from nose.tools import assert_equals, nottest

from account import Account, CHECKING, SAVINGS
from customer import Customer

def test_statement(name, accounts, amounts):
customer = Customer(name)
stmt = None;
for i, account in enumerate(accounts):
customer.openAccount(account)
if account.accountType == CHECKING:
atype = "Checking"
elif account.accountType == SAVINGS:
atype = "Saving"
elif account.accountType == MAXI_SAVINGS:
atype = "Maxi Savings"
stmt += "\n\n“ + atype + " Account\n"
for accountAmounts in amounts[i]:
for amount in accountAmounts:
if amount > 0:
account.deposit(amount)
stmt += " deposit " + _toDollars(abs(amount))
elif amount < 0:
account.withdraw(-amount)
stmt += " withdraw " + _toDollars(abs(amount))
stmt += "\nTotal" + _toDollars(abs(account.balance))
stmt += "\n\nTotal In All Accounts " + _toDollars(customer.getTotalBalance())

assert_equals(customer.getStatement(), stmt)

def test_statement_call():
name = "Henry"
anum = 12345
accounts = []
atypes = [CHECKING, SAVINGS, MAXI_SAVINGS]
for atype in atypes):
account = Account(anum, atype)
accounts.append(account)
camount = [100, -50, -30]
samount = [100, -50, 10]
mamount = [1000, 500, -2000]
amounts = [amount, smount, mmount]
test_statement(name, accounts, amounts)

def test_multipleAccount(customerName, accounts):
customer = Customer(customerName)
for account in accounts:
customer.openAccount(account)
assert_equals(customer.numAccs(), len(accounts))

def test_multipleAccount_call():
name = "John"
anum = 12345
accounts = []
atypes = [CHECKING, SAVINGS, MAXI_SAVINGS, 10, None]
for atype in atypes:
account = Account(anum, atype)
accounts.append(account)
test_multipleAccount(name, accounts)

from account import Account, CHECKING, SAVINGS
from customer import Customer


def test_statement():
checkingAccount = Account(CHECKING)
savingsAccount = Account(SAVINGS)
henry = Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount)
checkingAccount.deposit(100.0)
savingsAccount.deposit(4000.0)
savingsAccount.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")


def test_oneAccount():
oscar = Customer("Oscar").openAccount(Account(SAVINGS))
assert_equals(oscar.numAccs(), 1)


def test_twoAccounts():
oscar = Customer("Oscar").openAccount(Account(SAVINGS))
oscar.openAccount(Account(CHECKING))
assert_equals(oscar.numAccs(), 2)


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