def main(): account = Account(TransactionRepository(Clock()), StatementPrinter(Console())) account.deposit(1000) account.withdraw(100) account.deposit(500) account.print_statement()
def test_add_account(self): bank = Bank() account_1 = Account("001", 50) account_2 = Account("002", 100) bank.add_account(account_1) bank.add_account(account_2) self.assertEqual(len(bank.accounts), 2)
def test_add_account(self): """Test add bank account """ bank = Bank() account_1 = Account('001', 50) account_2 = Account('002', 30) bank.add_account(account_1) bank.add_account(account_2) self.assertEqual(len(bank.accounts), 2)
class AccountTest(TestCase): def setUp(self): self.transaction_repository = mock() self.account = Account(self.transaction_repository, None) def test_account_should_store_a_deposit_transaction(self): self.account.deposit(100) verify(self.transaction_repository).store(100) def test_account_should_store_a_withdraw_transaction(self): self.account.withdraw(50) verify(self.transaction_repository).store(-50)
def create_account(self, account_id): if not self.account_exists(account_id): self.accounts[account_id] = Account(account_id) return self.get_account(account_id) return None
def test_get_account_balance(self): bank = Bank() account_1 = Account("001", 50) bank.add_account(account_1) self.assertEqual(bank.get_account_balance("001"), 50)
class CardTest(unittest.TestCase): def setUp(self): self.acc = Account(name="John", surname="Doe") def test_basic(self): # given card = self.acc.create_new_card(4321) # when owner = card.owner # then self.assertEquals(owner, self.acc.owner) def test_check_pin(self): # given pin = 12345 card = self.acc.create_new_card(pin) # when is_pin_ok = card.check_pin(pin) # then self.assertTrue(is_pin_ok) def test_get_account(self): # given pin = 12345 card = self.acc.create_new_card(pin) # when account = card.get_account() # then self.assertEqual(account, self.acc) @unittest.expectedFailure def test_is_pin_number(self): # given pin = 'abc12345' card = self.acc.create_new_card(pin) # when is_pin_ok = card.is_pin_number() # then self.assertTrue(is_pin_ok)
def test_get_account_balance(self): """Test get account balance """ bank = Bank() account_1 = Account('001', 50) bank.add_account(account_1) self.assertEqual(bank.get_account_balance('001'), 50)
class TestAccount(unittest.TestCase): def setUp(self): self.account = Account(100) def test_deposit(self): self.account.deposit(10) assert self.account.balance == 10 def test_withdraw_invalid(self): assert self.account.withdraw(1) == False def test_withdraw_success(self): self.account.deposit(1) assert self.account.withdraw(1) == True def test_get_balance(self): assert self.account.get_balance() == 0 self.account.deposit(1) assert self.account.get_balance() == 1
def test_print_statement_containing_all_transactions(self): console = mock() clock = mock() when(clock).date_as_string().thenReturn('01/04/2015').thenReturn( '02/04/2015').thenReturn('10/04/2015') account = Account(TransactionRepository(clock), StatementPrinter(console)) account.deposit(1000) account.withdraw(100) account.deposit(500) account.print_statement() inorder.verify(console).print_line('DATE | AMOUNT | BALANCE') inorder.verify(console).print_line('10/04/2015 | 500.00 | 1400.00') inorder.verify(console).print_line('02/04/2015 | -100.00 | 900.00') inorder.verify(console).print_line('01/04/2015 | 1000.00 | 1000.00')
def test_print_statement_containing_all_transactions(self): console = mock() clock = mock() when(clock).date_as_string().thenReturn('01/04/2015').thenReturn('02/04/2015').thenReturn('10/04/2015') account = Account(TransactionRepository(clock), StatementPrinter(console)) account.deposit(1000) account.withdraw(100) account.deposit(500) account.print_statement() inorder.verify(console).print_line('DATE | AMOUNT | BALANCE') inorder.verify(console).print_line('10/04/2015 | 500.00 | 1400.00') inorder.verify(console).print_line('02/04/2015 | -100.00 | 900.00') inorder.verify(console).print_line('01/04/2015 | 1000.00 | 1000.00')
class TestAccount(unittest.TestCase): def setUp(self): self.client = Client(1) self.account = Account(1, self.client) # def testOverdraft(self): # self.account.withdraw(600) # self.assertTrue(self.account.overdraft) def testBalance(self): self.assertEquals(500.00, self.account.getBalance())
def test_create_account(): # Given account_number = 9876 initial_balance = 99 # When account = Account(account_number, initial_balance) # Then assert account.account_number == account_number assert account.balance == initial_balance
def test_account_if_existing(self): account = Account("001", 50) self.assertEqual(account.existing_account(001), None)
def Create_Account(self, account_number, balance): a = Account(account_number, balance) BANK.add_account(a)
print("1: Create an account") print("2: Log in to your account") print("3: Type \"stop\" to leave the bank") cmd = input() if cmd == "stop": stop = True elif cmd == "1": print("What is your name?") name = input() print("Choose your account number.") account = input() print("Choose your pin number.") pin_number = input() user = create_user(name, account, pin_number) print("Account created! Welcome, {}".format(user.name)) carter = User("Carter", 123, 1) account = Account(123, 1000, "checking") print("{} has account number {} with a pin number {}".format( carter.name, carter.account, carter.pin_number)) print("{} account with account number {} has balance {}".format( account.type, account.account_number, account.balance)) account.deposit(1000) print(account.check_balance()) account.withdraw(500) print(account.check_balance()) print("{} account with account number {} has balance {}".format( account.type, account.account_number, account.balance))
def create_account(account_number, balance, type): return Account(account_number, balance, type)
def closed_account(): account = Account() account.open() account.close() return account
def new_account(): account = Account() return account
def payee_account(): return Account(PAYEE_ACCOUNT_NUMBER, 0)
def opened_account(): account = Account() account.open() return account
def i_create_the_following_account(step): for row in step.hashes: a = Account(row['account_number'], row['balance']) BANK.add_account(a)
def payer_account(): return Account(PAYER_ACCOUNT_NUMBER, INITIAL_BALANCE)
def alternative_account(): return Account(ALTERNATIVE_ACCOUNT_NUMBER, INITIAL_BALANCE)
from flask import Flask, render_template, request from bank.bank import Bank from bank.account import Account app = Flask(__name__) BANK = Bank() @app.route('/') def hello_world(): # return 'Hello World!' account_number = request.args.get('account_number') balance = BANK.get_account_balance(account_number) return render_template('index.html', balance=balance) if __name__ == '__main__': import cProfile account = Account('1111', 50) #pylint: disable=C0103 BANK.add_account(account) cProfile.run('app.run(debug=True)', sort='time') # app.run(debug=True)
def setUp(self): self.transaction_repository = mock() self.account = Account(self.transaction_repository, None)
def test_account_object_returns_current_balance(self): account = Account("001", 50) self.assertEquals(account.account_number, "001") self.assertEquals(account.balance, 50)
def test_transactions(initial, added, withdrawn, remaining): account = Account(initial) account.add_cash(added) account.withdraw_cash(withdrawn) assert account.balance == remaining
def setUp(self): self.account = Account(100)
def test_account_object_can_be_created(self): account = Account()
def i_create_account_with_balance_of_group1(step, account_number, balance): a = Account(account_number, balance) BANK.add_account(a)
def setUp(self): self.client = Client(1) self.account = Account(1, self.client)
def test_lacking_balance(self): account = Account("001", 50) account.get_balance() self.assertEqual(account.balance,50)