Exemplo n.º 1
0
def test_withdrawals():
    checkingAccount = Account(CHECKING)
    oscar = Customer("Oscar").openAccount(checkingAccount)
    checkingAccount.deposit(1000.0, datetime(2016, 4, 12))
    checkingAccount.deposit(1000.0, datetime(2016, 4, 15))
    checkingAccount.deposit(1000.0, datetime(2016, 4, 17))
    assert_almost_equals(oscar.totalInterestEarned(), 0.17, places=2)
    checkingAccount.withdraw(1000.0, datetime(2016, 4, 19))
    assert_almost_equals(oscar.totalInterestEarned(), 0.12, places=2)
Exemplo n.º 2
0
def test_transferAmount():
    checkingAccount = Account(CHECKING)
    savingsAccount = Account(SAVINGS)
    oscar = Customer("Oscar").openAccount(checkingAccount)
    oscar.openAccount(savingsAccount)
    checkingAccount.deposit(100.0)
    transfered = oscar.transfer(checkingAccount, savingsAccount, 10)
    assert_equals(transfered, True)
    assert_equals(savingsAccount.amount, 10.)
Exemplo n.º 3
0
def test_transferAmountBelowZero():
    checkingAccount = Account(CHECKING)
    savingsAccount = Account(SAVINGS)
    oscar = Customer("Oscar").openAccount(checkingAccount)
    oscar.openAccount(savingsAccount)
    try:
        oscar.transfer(checkingAccount, savingsAccount, -1)
    except ValueError as e:
        result = str(e)
    assert_equals(result, 'Incorrect amount, should be more than 0')
Exemplo n.º 4
0
def test_transferNotEnoughFunds():
    checkingAccount = Account(CHECKING)
    savingsAccount = Account(SAVINGS)
    oscar = Customer("Oscar").openAccount(checkingAccount)
    oscar.openAccount(savingsAccount)
    try:
        oscar.transfer(savingsAccount, savingsAccount, 10)
    except ValueError as e:
        result = str(e)
    assert_equals(result, 'Incorrect amount, should be more than '
                          'source account amount')
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 check_transfer_account():
    checkingAccount = Account(CHECKING)
    savingsAccount = Account(SAVINGS)
    henry = Customer("Henry").openAccount(checkingAccount).openAccount(savingsAccount)
    checkingAccount.deposit(100.0)
    savingsAccount.deposit(4000.0)
    savingsAccount.transfer(checkingAccount, 100)
    henry.getStatement()
    assert_equals(henry.getStatement(), 'Statement for Henry\n\n'
                                        'Checking Account\n  deposit $100.00\n '
                                        ' deposit $100.00\nTotal $200.00\n\nSavings Account\n '
                                        ' deposit $4000.00\n  withdrawal $100.00\nT'
                                        'otal $3900.00\n\nTotal In All Accounts $4100.00')
Exemplo n.º 7
0
 def test_transfer(self):
     checkingAccount = CheckingAc()
     savingsAccount = SavingsAc()
     oscar = Customer("Oscar").openAccount(checkingAccount)
     oscar.openAccount(savingsAccount)
     checkingAccount.deposit(100.0)
     savingsAccount.deposit(4000.0)
     savingsAccount.withdraw(200.0)
     todayDate = datetime.now()
     savingsAccount.transfer(500.0, checkingAccount, todayDate)
     assert_equals(oscar.getStatement(),
                   "Statement for Oscar" +
                   "\n\nChecking Account\n  deposit $100.00\n  deposit $500.00\nTotal $600.00" +
                   "\n\nSavings Account\n  deposit $4000.00\n  withdrawal $200.00\n  withdrawal $500.00\nTotal $3300.00" +
                   "\n\nTotal In All Accounts $3900.00")
Exemplo n.º 8
0
 def transfer(self, initial_account, final_account, amount):
     if amount <= 0:
         raise ValueError("amount must be greater than zero")
     elif Customer.numAccs() <= 1:
         raise ValueError("You must have at least 2 accounts")
     else:
         self.accountType = initial_account
         self.withdraw(amount)
         self.accountType = final_account
         self.deposit(amount)
Exemplo n.º 9
0
def test_threeAccounts():
    oscar = Customer("Oscar").openAccount(Account(SAVINGS))
    oscar.openAccount(Account(CHECKING))
    oscar.openAccount(Account(MAXI_SAVINGS))
    assert_equals(oscar.numAccs(), 3)
Exemplo n.º 10
0
def test_oneAccount():
    oscar = Customer("Oscar").openAccount(Account(SAVINGS))
    assert_equals(oscar.numAccs(), 1)
Exemplo n.º 11
0
def test_threeAccounts():
    oscar = Customer("Oscar").openAccount(SavingsAcc())
    oscar.openAccount(CheckingAcc()).openAccount(MaxiSavingsAcc())
    assert_equals(oscar.numAccs(), 3)
Exemplo n.º 12
0
def test_oneAccount():
    oscar = Customer("Oscar").openAccount(SavingsAcc())
    assert_equals(oscar.numAccs(), 1)
Exemplo n.º 13
0
 def test_twoAccounts(self):
     oscar = Customer("Oscar").openAccount(SavingsAc())
     oscar.openAccount(CheckingAc())
     assert_equals(oscar.numAccs(), 2)