def test_deposit_adds_multiple_transactions(self, mock_transaction_constructor, mock_date):
        mock_transaction = mock_transaction_constructor.return_value
        mock_date.today.side_effect = [
            date(2012, 1, 10),
            date(2012, 1, 13)
        ]

        mock_transaction_history = Mock()
        account = Account(transaction_history=mock_transaction_history)

        account.deposit(1000)
        account.deposit(2000)

        mock_transaction_constructor.assert_has_calls(
            [
                call(1000, date(2012, 1, 10)),
                call(2000, date(2012, 1, 13))
            ]
        )

        mock_transaction_history.add.assert_has_calls(
            [
                call(mock_transaction),
                call(mock_transaction)
            ]
        )
def test_negative_deposits_converted_to_positive():
    """
    Given a negative amount argument for deposit, the amount value is converted
    to positive.
    """
    account = Account()
    amount = -300
    account.deposit(amount)
    assert account.get_balance() == 300
def test_withdrawal_converted_to_negative():
    """
    Given a positive amount argument for deposit, the amount value is converted
    to negative.
    """
    account = Account()
    amount = 80
    account.withdraw(amount)
    assert account.get_balance() == -80
    def test_deposit_adds_one_deposit_transaction(self, mock_transaction_constructor, mock_date):
        mock_transaction = mock_transaction_constructor.return_value
        mock_date.today.return_value = date(2012, 1, 10)
        mock_transaction_history = Mock()

        account = Account(transaction_history=mock_transaction_history)
        account.deposit(1000)

        mock_transaction_constructor.assert_called_with(1000, date(2012, 1, 10))
        mock_transaction_history.add.assert_called_with(mock_transaction)
Example #5
0
def test_account():
    test = Account(60, "tester")

    print("Try to add to much interest")
    test.interest(70)
    print("Attempt to over withdrawl account")
    test.withdrawl(70)
    test.withdrawl(60)
    print("Withdrawl almosteverything.", test.pretty_balance())
    test.deposit(60)
    print("New Balanmce should be 63:")
    print(test.pretty_balance())
    def test_withdraw_adds_one_withdraw_transactions(self, mock_transaction_constructor, mock_date):
        mock_transaction = mock_transaction_constructor.return_value
        mock_date.today.return_value = date(2012, 1, 14)

        mock_transaction_history = Mock()
        account = Account(transaction_history=mock_transaction_history)

        account.withdraw(500)

        mock_transaction_constructor.assert_called_with(500, date(2012, 1, 14))

        mock_transaction_history.add.assert_called_with(mock_transaction)
def test_withdrawal_appended_to_transactions():
    """The withdraw instance is appended to transactions"""
    account = Account()
    account.deposit(-300)
    account.withdraw(80)
    account.withdraw(120)
    # all of the withdraw instances or 'transactions' should be in Account(object)
    data = ast.literal_eval(repr(account.transactions))
    assert account.get_balance() == sum(row[0] for row in data)
def test_deposit_appended_to_transactions():
    """The deposit instance is appended to transactions"""
    account = Account()
    account.deposit(-300)
    account.deposit(100)
    account.deposit(30.59)
    # all of the deposit instances or 'transactions' are included Account(object)
    data = ast.literal_eval(repr(account.transactions))
    assert sum(row[0] for row in data) == 430.59
Example #9
0
def get_accounts():
    accounts_list = Account.get_accounts()
    if accounts_list:
        return select_account(0, 5, accounts_list)
    else:
        print("There are no accounts.")
        input("\nPress enter to return to the account menu: ")
        main_menu()
def test_account_balance_series_of_transactions():
    """
    Given some transaction instances, the balance should be the sum total
    of all transacation instances
    """
    acc = Account()
    acc.deposit(100)
    acc.withdraw(90)
    acc.deposit(10)
    data = ast.literal_eval(repr(acc.transactions))
    assert sum(row[0] for row in data) == 20
Example #11
0
def select_account(page, pagesize, accounts):
    clear_output()
    start = page * pagesize
    end = (page + 1) * pagesize
    sub_set = accounts[start:end]
    next_page_exists = False
    prev_page_exists = False
    if len(sub_set) == pagesize:
        sub_set.append("Next page")
        next_page_exists = True
    if page > 0:
        sub_set.insert(0, "Previous page")
        prev_page_exists = True
    selection = validation.display_options(sub_set, "Choose an account: ")
    if selection == len(sub_set) and next_page_exists:
        return select_account(page + 1, pagesize, accounts)
    if selection == 1 and prev_page_exists:
        return select_account(page - 1, pagesize, accounts)
    account_num = sub_set[selection - 1].split(":")[0].split(" ")[1]
    temp_user, temp_account = Account.set_account(account_num)
    return temp_user, temp_account
    def test_print_statement_for_one_transaction(self,
            mock_bank_statement_constructor,
            mock_transaction_constructor,
            mock_date
            ):
        mock_transaction = mock_transaction_constructor.return_value
        mock_bank_statement = mock_bank_statement_constructor.return_value
        mock_date.today.return_value = date(2012, 1, 14)

        mock_output = Mock()
        mock_transaction_history = Mock()

        account = Account(transaction_history=mock_transaction_history, output=mock_output)

        account.deposit(500)
        account.print_statement()

        mock_bank_statement_constructor.assert_called_with(mock_transaction_history)
        mock_output.write.assert_called_with(str(mock_bank_statement))
Example #13
0
 def customer(self,balance):
     self.account = Account(balance)
Example #14
0
def create_account(user):
    initial_deposit = validation.validate_float("initial deposit amount")
    return Account(user.customer_id, initial_deposit)
def test_no_transactions_return_0_balance():
    """Given no transaction instances, the balance should be 0"""
    account = Account()
    data = ast.literal_eval(repr(account.transactions))
    # there are neither any previous deposit or withdraw transactions
    assert sum(row[0] for row in data) == 0
Example #16
0
class TestAccount:
    def setup_class(self):
        self.account1 = Account(1)
        self.account2 = Account(2)

    def teardown_class(self):
        pass

    def test_check_balance(self):
        assert self.account1.check_balance() == 0
        assert self.account2.check_balance() == 0

    def test_deposit(self):
        self.account1.deposit(200)
        assert self.account1.check_balance() == 200

    def test_withdraw(self):
        self.account1.withdraw(150)
        assert self.account1.check_balance() == 50

    def test_withdraw_limit(self):
        assert self.account1.withdraw(250) == False

    def test_transfer(self):
        self.account1.deposit(150)
        self.account1.transfer(self.account2, 50)
        assert self.account2.check_balance() == 50
Example #17
0
 def setup_class(self):
     self.account1 = Account(1)
     self.account2 = Account(2)
Example #18
0
          "6.Check Balance\n"
          "7.Set Account\t"
          "8.Get Account\n"
          "9.quit\n")

    ans = input("do you want to input another Customer y/n ?")
    if ans == 'y':
        firstname = input("please input the firstname")
        lastname = input("please input the lastname")
        account = input("please input the account")
        names.append(namelist)
    else:
        break
    money = 0
    balance = int(money)
    Balance = Account(balance)
    while True:
        j = int(input("how much do you want withdraw?"))
        Balance.withdraw(j)
        if Balance.getBalance(balance) < 0:
            print("not enough money")
            Balance.deposit(j)
            continue
        else:
            print(Balance.getBalance(balance), "$")

        break

    while True:
        j = input("")
        if j == "1":