Beispiel #1
0
    def test_basic_deposit(self):
        t = 0
        b = BankAccount('Wells Fargo', 100, 0, t)
        assert_equals(b.balance(t), 0)

        b.deposit(100, t+1)
        assert_equals(b.balance(t-10), 0)
        assert_equals(b.balance(t), 0)
        assert_equals(b.balance(t+1), 0)
        assert_equals(b.balance(t+2), 100)
        assert_equals(b.balance(t+10), 100)
        assert_equals(b.balance(t+100), 100)
Beispiel #2
0
    def test_withdrawal_overdraft_prevention(self):
        t = 0
        b = BankAccount('Wells Fargo', 100, 200, t)
        assert_equals(b.balance(t), 0)
        assert_equals(b.balance(t+1), 200)

        b.withdraw(4000, t+1)
        assert_equals(b.balance(t+1), 200)
        assert_equals(b.balance(t+2), 200)
        assert_equals(b.balance(t+10), 200)
        assert_equals(b.balance(t+100), 200)
Beispiel #3
0
    def test_basic_withdrawal(self):
        t = 0
        b = BankAccount('Wells Fargo', 100, 200, t)
        assert_equals(b.balance(t+1), 200)

        b.withdraw(100, t+1)
        assert_equals(b.balance(t+1), 200)
        assert_equals(b.balance(t+2), 100)
        assert_equals(b.balance(t+10), 100)
        assert_equals(b.balance(t+100), 100)
Beispiel #4
0
    def test_input_pipe(self):
        t = 0
        amount = Amount(10, USD)
        flow = PeriodicFlow(name="testFlow", period=10, stime=5, etime=45, amount=amount)
        account = BankAccount('Bank', 100, 0, t)
        pipe = InputPipe(name="testPipe", flow=flow, account=account)
        assert_equals(account.balance(t), 0)

        pipe.start_flow(t)

        # Test that nothing gets tranfered for for T + 1 --> t + 5
        for i in range(1, 6):
            pipe.flush(t+i)
            assert_equals(account.balance(t+i), 0)
            assert_equals(account.balance(t+i+1), 0)

        # Flush until T+6, and verify that a transfer happens!
        pipe.flush(t+6)
        assert_equals(account.balance(t+6), 10)
        assert_equals(account.balance(t+7), 10)

        # Flush until T+16, and verify that a transfer happens!
        pipe.flush(t+16)
        assert_equals(account.balance(t+16), 20)
        assert_equals(account.balance(t+17), 20)
Beispiel #5
0
    def test_deposit_time_travel(self):
        t = 0
        b = BankAccount('Wells Fargo', 100, 1000, t)

        assert_equals(b.balance(t+4), 1000)
        b.deposit(500, t+1)
        assert_equals(b.balance(t+2), 1500)
        assert_equals(b.balance(t+3), 1500)
        assert_equals(b.balance(t+4), 1500)
Beispiel #6
0
    def test_withdrawal_time_travel(self):
        t = 0
        b = BankAccount('Wells Fargo', 100, 1000, t)

        assert_equals(b.balance(t+4), 1000)
        b.withdraw(500, t+1)
        assert_equals(b.balance(t+2), 500)
        assert_equals(b.balance(t+3), 500)
        assert_equals(b.balance(t+4), 500)