コード例 #1
0
ファイル: test_banking.py プロジェクト: mikosco4real/banking
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
コード例 #2
0
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)
コード例 #3
0
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
コード例 #4
0
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
コード例 #5
0
    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)
コード例 #6
0
          "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":
            print(customer.account())
            break
        if j == "2":