コード例 #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 * DateProvider.getTotalDaysPassedRatio())
コード例 #2
0
def test_maxi_savings_account():
    bank = Bank()
    checkingAccount = Account(MAXI_SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))
    year_behind = datetime.datetime.now() - datetime.timedelta(365)
    checkingAccount.deposit(3000.0, year_behind)
    assert_equals(bank.totalInterestPaid(), 150.0)
コード例 #3
0
def test_checking_account():
    bank = Bank()
    bill = bank.addCustomer("Bill")
    bill_new_checking = bill.openAccount('CHECKING')
    bill_new_checking.deposit(100.00)
    bill_new_checking.account_age_in_days = 20
    assert_equals(round(bank.totalInterestPaid(),3), .005)
コード例 #4
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)
コード例 #5
0
def test_checking_account():
    bank = Bank()
    checkingAccount = Account(CHECKING)
    bill = Customer("Bill").openAccount(checkingAccount)
    bank.addCustomer(bill)
    year_behind = datetime.datetime.now() - datetime.timedelta(365)
    checkingAccount.deposit(100.0, year_behind)
    assert_equals(bank.totalInterestPaid(), 0.1)
コード例 #6
0
def test_maxi_savings_account_with_withdrawals():
    bank = Bank()
    checkingAccount = Account(MAXI_SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(checkingAccount))
    year_behind = datetime.datetime.now() - datetime.timedelta(365)
    five_days_behind = datetime.datetime.now() - datetime.timedelta(5)
    checkingAccount.deposit(3000.0, year_behind)
    checkingAccount.withdraw(1000.0, five_days_behind)
    assert_almost_equals(bank.totalInterestPaid(), 147.97, places=2)
コード例 #7
0
ファイル: bank_tests.py プロジェクト: gishaj/abc-bank-python
class TestBank:

    def setUp(self):
        self.bank = Bank()

    def tearDown(self):
        pass

    def test_customer_summary(self):
        john = Customer("John").openAccount(SavingsAc())
        self.bank.addCustomer(john)
        assert_equals(self.bank.customerSummary(),
                      "Customer Summary\n - John (1 account)")

    def test_checking_account(self):
        checkingAccount = CheckingAc()
        bill = Customer("Bill").openAccount(checkingAccount)
        self.bank.addCustomer(bill)
        txnDate = datetime.strptime('May 1 2016  10:14AM', '%b %d %Y %I:%M%p')
        checkingAccount.deposit(100.0, txnDate)
        txnDate = datetime.strptime('May 5 2016  3:21PM', '%b %d %Y %I:%M%p')
        checkingAccount.deposit(200.0, txnDate)
        #since we moved over to daily interest and the total interest
        # is calculated on a daily basis, this result will change
        # assert_equals(self.bank.totalInterestPaid(), 0.1)
        assert_equals(self.bank.totalInterestPaid(), 0.00410958904109589)


    def test_savings_account(self):
        savingsAccount = SavingsAc()
        self.bank.addCustomer(Customer("Bill").openAccount(savingsAccount))
        txnDate = datetime.strptime('May 1 2012  10:14AM', '%b %d %Y %I:%M%p')
        savingsAccount.deposit(100.0, txnDate)
        assert_equals(self.bank.totalInterestPaid(), 0.40273972602739727)

    def test_maxi_savings_account(self):
        maxiSavingsAccount = MaxiSavingsAc()
        self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount))
        txnDate = datetime.strptime('Feb 5 2012  4:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.deposit(3000.0,txnDate)
        # Different interest after maxi interst calculation logic is changed
        # assert_equals(self.bank.totalInterestPaid(), 170.0)
        assert_equals(self.bank.totalInterestPaid(), 639.4520547945206)

    def test_maxi_savings_account_recent_withdrawal(self):
        maxiSavingsAccount = MaxiSavingsAc()
        self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount))
        txnDate = datetime.strptime('Feb 5 2012  3:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.deposit(200.0, txnDate)
        txnDate = datetime.strptime('Feb 5 2012  4:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.deposit(3000.0, txnDate)
        # Putting a date in the future, which should fail elsewhere in the ideal
        # scenario, but this is to ensure that this test case passes for a longtime
        txnDate = datetime.strptime('May 9 2016  3:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.withdraw(100.0, txnDate)
        assert_equals(self.bank.totalInterestPaid(), 0.008493150684931507)

    def test_maxi_savings_account_nonrecent_withdrawal(self):
        maxiSavingsAccount = MaxiSavingsAc()
        self.bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount))
        txnDate = datetime.strptime('Feb 5 2012  3:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.deposit(200.0, txnDate)
        txnDate = datetime.strptime('Feb 5 2012  4:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.deposit(3000.0, txnDate)
        txnDate = datetime.strptime('Mar 19 2012  3:21PM', '%b %d %Y %I:%M%p')
        maxiSavingsAccount.withdraw(100.0, txnDate)
        assert_equals(self.bank.totalInterestPaid(), 642.5068493150685)
コード例 #8
0
def test_maxi_savings_account():
    bank = Bank()
    maxiSavingsAccount = Account(MAXI_SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(maxiSavingsAccount))
    maxiSavingsAccount.deposit(3000.0)
    assert_equals(bank.totalInterestPaid(), maxiSavingsAccount.interestEarned())
コード例 #9
0
def test_savings_account():
    bank = Bank()
    savingsAccount = Account(SAVINGS)
    bank.addCustomer(Customer("Bill").openAccount(savingsAccount))
    savingsAccount.deposit(1500.0)
    assert_equals(bank.totalInterestPaid(), savingsAccount.interestEarned())
コード例 #10
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)