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
83 changes: 53 additions & 30 deletions tests/customer_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,56 @@
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)
def test_statement(name, accounts, transactions):
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 transaction in transactions[i]
if transaction.amount > 0:
account.deposit(amount)
stmt += " deposit " + _toDollars(abs(amount))
elif transaction.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(henry.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]
transactions = [amount, smount, mmount]
test_statement(name, accounts, transactions)

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)