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)
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)
class TestAccount(unittest.TestCase): def setUp(self): self.bank = Bank() self.account_1 = Account(001, 50) self.account_2 = Account(002, 100) def test_bank_is_initially_empty(self): self.assertEqual({}, self.bank.accounts) self.assertEqual(len(self.bank.accounts), 0) def test_add_account(self): # bank = Bank() self.bank.add_account(self.account_1) self.bank.add_account(self.account_2) self.assertEqual(len(self.bank.accounts), 2) def test_get_account_balance(self): # bank = Bank() # self.account_1 = Account(001, 50) self.bank.add_account(self.account_1) self.assertEqual(self.bank.get_account_balance(001), 50)
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)
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)
def test_deposit(self): bank = Bank() account_1 = Account(001, 50) bank.add_account(account_1) self.assertEqual(bank.deposit(001, 50), 100) self.assertEqual(bank.deposit(002, 50), 'Account does not exist')
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 TestBank(unittest.TestCase): def setUp(self): self.bank = Bank() def test_bank_is_initially_empty(self): self.assertEquals({}, self.bank.accounts) self.assertEquals(len(self.bank.accounts), 0) def test_add_account(self): account_1 = Account("001", 50) self.bank.add_account(account_1) self.assertEquals(self.bank.get_account_balance("001"), 50)
def test_withdraw(self): bank = Bank() account_1 = Account(001, 50) bank.add_account(account_1) self.assertEqual(bank.withdraw(001, 50), 0) self.assertEqual(bank.withdraw(001, 100), 'Insufficient balance') self.assertEqual(bank.withdraw(002, 50), 'Account does not exist')
def test_bank_allow_withdraw(self): bank = Bank() account_test = Account("003", 100) bank.add_account(account_test) bank.withdraw_amount("003",5) self.assertEqual(int(bank.get_account_balance("003")) - 5, 95)
def test_bank_is_initially_empty(self): bank = Bank() self.assertEqual({}, bank.accounts) self.assertEqual(len(bank.accounts), 0)
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 given_account_number_0001_is_a_valid_account(step): account = Account(0001, 50) bank = Bank() bank.add_account(account)
"""This is the main bank app""" from flask import Flask, render_template, request from bank.account import Account from bank.bank import Bank app = Flask(__name__) #pylint: disable=C0103 BANK = Bank() @app.route('/') def 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)') #cProfile.run('app.run(debug=True)', sort='time')
"""This is a docstring""" 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(): """This is another function""" 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 BANK.add_account(Account('1111', 50)) cProfile.run('APP.run(debug=True)', sort='time')
def test_does_account_exist(self): bank = Bank() account_1 = Account(001,400) bank.add_account(account_1) self.assertEqual(bank.does_account_exist(002),False) self.assertEqual(bank.does_account_exist(001),True)
if __name__ == "__main__": if len(sys.argv) == 2: file = sys.argv[1] file_exists = os.path.isfile(file) if not file_exists: print("O arquivo de entrada não existe ou não foi encontrado.") sys.exit() else: print("Número inválido de argumentos. Informe o arquivo de entrada.") sys.exit() data_file = open(file, 'r') data_lines = data_file.readlines() data_file.close() bank = Bank() for line in data_lines: source_uuid, balance, name, date, amount, receiver_uuid = line.strip( ).split('-%p') account = Account(balance) customer = Customer(source_uuid, name, account) transaction = Transaction(source_uuid, receiver_uuid, amount, parse_date(date)) bank.add_customer(customer) bank.add_transaction(transaction) bank.process_transactions()
def setUp(self): self.bank = Bank()
def setUp(self): self.bank = Bank() self.account_1 = Account(001, 50) self.account_2 = Account(002, 100)
def test_bank_is_initially_empty(self): """Test bank if it is initially empty""" bank = Bank() self.assertEqual({}, bank.accounts) self.assertEqual(len(bank.accounts), 0)
def test_withdraw(self): bank = Bank() account_1 = Account(001, 50) bank.add_account(account_1) self.assertEqual(bank.withdraw(001,20), 30)
"""DOCSTRING""" from flask import Flask, render_template, request from bank.account import Account from bank.bank import Bank APP = Flask(__name__) BANK = Bank() @APP.route('/') def run_site(): """run site""" 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) BANK.add_account(ACCOUNT) cProfile.run('APP.run(debug=True)', sort='time')
def main(): """ main method for application """ bank = Bank() flag = True while flag: # ----- # DISPLAY WELCOME MESSAGE AND HOW BANK MAY HELP USER # ----- print(f"welcome to {bank.BANK_NAME}\n".center(50, " ")) print(bank.how_can_we_help()) response = user_response_controller(bank.BANK_REQUESTS.get('hcwh'), input_prompt()) if isinstance(response, list): if response[0] == 'resend_same_bank_request': reason_for_resend(response[1]) else: if response == 1: # ----- # CREATE BANK ACCOUNT # this process should continue until user stops it by his reponse # or successfully create a bank account # ----- account_creation_flag = True while account_creation_flag: creation_response = create_bank_account_helper(bank) if isinstance(creation_response, list): # if account creation is successful if creation_response[0]: print(creation_response[1]) account_creation_flag = False else: reason_for_resend(creation_response[1]) elif response == 2: authentication_flag = True while authentication_flag: # ---- # FIRST AUTHENTICATE THE ACCOUNT # Before a user can perform any transaction, they first need to be # authenticated # ---- auth_response = authenticate_an_account_helper(bank) # when auth credentials fails to authenticate, display why and # re-initiate the login process if auth_response[0] == False: reason_for_resend(auth_response[1]) # when auth credentials passes authentication, then display available # transactions that can be processed by the authenticated user else: transaction_flag = True while transaction_flag: # ------ # PROCESS USER TRANSACTIONS # process reponse of user for transaction computations # ------ print(bank.get_core_transactions()) response = user_response_controller( bank.BANK_REQUESTS.get('trans'), input_prompt()) # if a user doesn't choose the correct outlisted option if isinstance(response, list): if response[0] == "resend_same_bank_request": reason_for_resend(response[1]) # if a user chooses correct outlisted option else: # check balance if response == 1: print( f"Your current balance is: {bank.get_user_account_balance()}" ) # process withdrawal elif response == 2: process_withdrawal_flag = True # ----- # PROCESS WITHDRAWAL # this process will continue until user inputs # a valid detail or cancel operation # ----- while process_withdrawal_flag: withdrawal_response = withdrawal_helper( bank) if withdrawal_response[0]: print(withdrawal_response[1]) process_withdrawal_flag = False else: reason_for_resend( withdrawal_response[1]) # process transfer elif response == 3: # ------ # PROCESS FUND TRANSFER # this process will continue until user inputs # a valid detail or cancel operation # ------ process_transfer_flag = True while process_transfer_flag: transfer_response = tranfer_amount_helper( bank) # if transfer is successful if transfer_response[0]: print(transfer_response[1]) process_transfer_flag = False # if transfer is unsuccessful else: reason_for_resend( transfer_response[1]) break break
def test_existing_account(self): bank = Bank() account_1 = Account(001, 50) bank.add_account(account_1) self.assertEqual(bank.account_exist(001), None)
from flask import Flask, render_template, request from bank.bank import Bank app = Flask(__name__) BANK = Bank() @app.route('/') def 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__": app.run(debug=True)
class BankTest(unittest.TestCase): def setUp(self): self.bank = Bank() def test_bank_is_initially_empty(self): self.assertEqual({}, self.bank.accounts) self.assertEqual(len(self.bank.accounts),0) def test_add_account(self): account_1 = Account("001",50) account_2 = Account("002", 100) self.bank.add_account(account_1) self.bank.add_account(account_2) self.assertEqual(len(self.bank.accounts),2) #self.assertEqual(len(self.bank.accounts),500) def test_get_account_balance(self): account_1 = Account("001", 50) self.bank.add_account(account_1) self.assertEqual(self.bank.get_account_balance("001"), 50) def test_withdraw_from_account(self): account_2 = Account("002", 100) self.bank.add_account(account_2) self.assertEqual(self.bank.withdraw_from("002", 50), 50) def test_withdraw_from_method_raises_typeerror_if_not_ints(self): account_2 = Account("002", 100) self.bank.add_account(account_2) self.assertRaises(TypeError, self.bank.withdraw_from, "002", "50") def test_withdraw_from_method_insufficient_amount(self): account_2 = Account("002", 100) self.bank.add_account(account_2) self.assertEqual(self.bank.withdraw_from("002", 120), 'Insufficient Funds')
def test_account_withdraw(self): bank = Bank() account_1 = Account(001, 50) bank.add_account(account_1) bank.account_withdraw(001,30) self.assertEqual(bank.get_account_balance(001), 20)