def test_get_balance(): """Test for getting a balance of account.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) assert account2.balance == 1000 assert account1.balance != account2.balance assert account1.balance in range(10)
def test_withdraw(): """Test for withdrawing some money from account.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) with pytest.raises(bank.TransactionError): account1.withdraw(10) account2.withdraw(25) assert account2.balance == 975
def test_deposit(): """Test for depositing some money to account.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) account1.deposit(100) assert account1.balance == 100 with pytest.raises(bank.TransactionError): account2.deposit(-10)
def test_debit_turnover(): """Test for a review of a total incomes of account between 2 dates.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) assert account1.get_debit_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == 0 account1.deposit(25) account2.transfer(987, account1) assert account1.get_debit_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) \ == 1012
def test_credit_turnover(): """Test for a review of costs of account between 2 dates.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) account2.withdraw(412) account2.transfer(214, account1) assert account1.get_credit_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == 0 assert account2.get_credit_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) \ == -626
def test_account_repr(): """Test for account's representation.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) random_number = "EE" + ''.join(random.choices(digits, k=18)) assert account1.__repr__() != random_number assert account2.__repr__() != random_number assert account2.__repr__() != account1.__repr__() assert "EE" in account1.__repr__() and "EE" in account2.__repr__() assert len(account1.__repr__()) == 20 and len(account2.__repr__()) == 20
def test_account_statement(): """Test for making a transactions' view of account between 2 dates.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) assert account1.account_statement(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == [] account1.deposit(157) account2.withdraw(212) account1.transfer(57, account2) assert len(account1.account_statement(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today())) \ == 2
def test_transfer(): """Test for transferring some money from one account to another.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) with pytest.raises(bank.TransactionError): account1.transfer(25, account2) with pytest.raises(bank.TransactionError): account2.transfer(100, account2) account2.transfer(599, account1) assert account2.balance == 396 # 401 - 5 since different banks. assert account1.balance == 599
def test_get_net_turnover(): """Test of overall statistics of account between 2 dates.""" account1 = bank.Account(0, person1, bank1) account2 = bank.Account(1000, person3, bank2) assert account1.get_net_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) \ == account2.get_net_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == 0 account2.withdraw(412) account2.transfer(214, account1) account1.deposit(25) account1.transfer(57, account2) assert account1.get_net_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == 182 assert account2.get_net_turnover(datetime.date.today() - datetime.timedelta(days=10), datetime.date.today()) == -569
def get_data(): fin = open("database.txt", "r") database = fin.read() database = database.split(sep='\n') for i in range(0, len(database) - 1): words = database[i].split(sep=' ') address = '' for j in range(bank.AccountInfo, len(words)): address += ' ' + words[j] Accounts.append( bank.Account(words[3], words[5], words[0], words[1], address, words[6], words[7], int(words[2]))) Accounts[i].deposit(int(words[4]), words[5]) fin.close()
def generate_random_account(): global fnames, lnames holder_name = fnames[randint(0, len(fnames) - 1)] + ' ' + lnames[randint( 0, len(lnames) - 1)] new_acc_no = bank.Account.get_new_acc_no() my_acc = bank.Account(new_acc_no, holder_name, randomDate("1/1/2009 12:00 AM", "1/1/2010 12:00 AM")) no_of_trans = randint(3, 10) for t in range(no_of_trans): amount = randint(500, 1000) if random() <= 0.5: amount *= -1 my_acc.make_transaction( bank.Transaction( amount, randomDate("1/1/2010 12:00 AM", "1/1/2016 12:00 AM"))) return my_acc
import bank acc = bank.Account('ABC', '1222-0001', 1000) #這裡用bank才知道來自哪裡 print(acc) #之後就認識acc了 acc.deposit(100) acc.withdraw(10) print(acc) #acc.__name ="" #如果bank.py沒有@property, 就會黏上來的新屬性還能印出來,但不會覆蓋舊的 acc.balance = -10 #測試setter.balance 的規則能否正常 運作 print('戶名:', acc.name) print('帳號:', acc.number) print('餘額:', acc.balance) acc1 = bank.Account.default('DEF', '1222-0002') print('戶名:', acc1.name) print('帳號:', acc1.number) print('餘額:', acc1.balance)
def setUp(self) -> None: self.accounts = [bank.Account(), bank.Account()]
File "<pyshell#223>", line 1, in <module> import greet.py ImportError: No module named greet.py >>> import sys >>> sys.path ['', 'D:\\sw\\Python27\\Lib\\idlelib', 'C:\\Users\\Dell lap\\Desktop\\Python\\lnt\\mysore\\aug-16-17-18-19', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'D:\\sw\\Python27\\DLLs', 'D:\\sw\\Python27\\lib', 'D:\\sw\\Python27\\lib\\plat-win', 'D:\\sw\\Python27\\lib\\lib-tk', 'D:\\sw\\Python27', 'D:\\sw\\Python27\\lib\\site-packages', 'D:\\sw\\Python27\\lib\\site-packages\\openpyxl-2.5.0a2-py2.7.egg'] >>> sys.path.append('C:\\Users\\Dell lap\\Desktop\\Python\\oracle\\python-selenium') >>> sys.path ['', 'D:\\sw\\Python27\\Lib\\idlelib', 'C:\\Users\\Dell lap\\Desktop\\Python\\lnt\\mysore\\aug-16-17-18-19', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'D:\\sw\\Python27\\DLLs', 'D:\\sw\\Python27\\lib', 'D:\\sw\\Python27\\lib\\plat-win', 'D:\\sw\\Python27\\lib\\lib-tk', 'D:\\sw\\Python27', 'D:\\sw\\Python27\\lib\\site-packages', 'D:\\sw\\Python27\\lib\\site-packages\\openpyxl-2.5.0a2-py2.7.egg', 'C:\\Users\\Dell lap\\Desktop\\Python\\oracle\\python-selenium'] >>> import greet >>> greet.sayhi() Hi from greet module >>> reload(greet) <module 'greet' from 'C:\Users\Dell lap\Desktop\Python\oracle\python-selenium\greet.pyc'> >>> import bank >>> ac1 = bank.Account('Aditya',10000000,'S') >>> ac1 <bank.Account object at 0x000000000397E668> >>> reload(bank) <module 'bank' from 'C:\Users\Dell lap\Desktop\Python\lnt\mysore\aug-16-17-18-19\bank.pyc'> >>> ac1 = bank.Account('Aditya',10000000,'S') >>> ac1 <bank.Account object at 0x000000000397E9B0> >>> str(ac1) '<bank.Account object at 0x000000000397E9B0>' >>> reload(bank) <module 'bank' from 'C:\Users\Dell lap\Desktop\Python\lnt\mysore\aug-16-17-18-19\bank.pyc'> >>> sys.path ['', 'D:\\sw\\Python27\\Lib\\idlelib', 'C:\\Users\\Dell lap\\Desktop\\Python\\lnt\\mysore\\aug-16-17-18-19', 'C:\\WINDOWS\\SYSTEM32\\python27.zip', 'D:\\sw\\Python27\\DLLs', 'D:\\sw\\Python27\\lib', 'D:\\sw\\Python27\\lib\\plat-win', 'D:\\sw\\Python27\\lib\\lib-tk', 'D:\\sw\\Python27', 'D:\\sw\\Python27\\lib\\site-packages', 'D:\\sw\\Python27\\lib\\site-packages\\openpyxl-2.5.0a2-py2.7.egg', 'C:\\Users\\Dell lap\\Desktop\\Python\\oracle\\python-selenium'] >>> sys.path.pop(2) 'C:\\Users\\Dell lap\\Desktop\\Python\\lnt\\mysore\\aug-16-17-18-19'
import bank acct = bank.Account('Justin', '123-4567', 1000) acct.deposit(500) acct.withdraw(200) # 顯示 Account('Justin', '123-4567', 1300) print(acct)
def setUp(self) -> None: self.account = bank.Account()
import bank a = bank.Account(1, 100, '2020-01-25', 'c', 10, 'PGPersistanceEngine') b = bank.Account(2, 200, '2020-01-18', 'd', 5, 'PGPersistanceEngine') #a.displayAcc() b.term_date = bank.date(2020, 1, 1) b.interest_recalc_date = bank.date(2020, 1, 30) #b.withdraw(450) b.displayAcc() #print(str(bank.date(2020,1,25))) #print(a.displayAcc()) #a.transfer(40, b) #x = a.gettrList() #print(x[2].amount) #print(type(a.opening_date)) #bank.Account.displayAcc(a) #bank.Account.displayAcc(b) pe = bank.PGPersistanceEngine(1, 100, '2020-1-25', 10, 'c', '2020-5-16', '2020-2-4') pe.persistAcc()
import bank client_1 = bank.Client('Rodrigo', 'Bernardo', '111484867-04') client_2 = bank.Client('Renata', 'Teixeira', '120132167-00') account_1 = bank.Account('123-4', client_1, 250.0, 1500.0) account_2 = bank.Account('124-0', client_2, 500.0, 2500.0) account_1.teste(1, 2) print(bank.Account.teste) print(account_1.teste) print(account_2.teste) print(account_1.withdraw) print(account_2.withdraw)
import bank b = bank.Account('Chaitanya', 11000000, 'USA near Google Headquarters') b.deposit(1000) b.withdraw(50000) print(b.__str__()) print(b.__repr__())
#C:Python31python.exe # -*- coding:utf-8 -*- import bank import xmath acct = bank.Account('Pingyao', '111-1111', 77777777) acct.deposit(900) acct.withdraw(200) print(acct.balance) a = xmath.max(100, 90) print(a) b = xmath.min(11, 99) print(b) c = xmath.suma(1, 2) print(c)
def show_menu(): print("Welcome to bank management system by alexcarchiar") print("Version 1.0") flag = 1 while (flag != 9): print("Available functions: press the right number key") print("1 - Create account") print("2- Delete account") print("3- Search account holder") print("4- Withdraw") print("5- Deposit") print("6- Modify account") print("7- Money transfer") print("8- Show all account holders") print("9- Close program") flag = int(input("Your choice: ")) if flag == 1: print("Fill in the information") type = input("Account type: ") currency = input("Currency: ") name = input("Name: ") surname = input("Last name: ") address = input("Address: ") doc_type = input("Document type: ") doc_num = input("Document number: ") number = int(input("Account number: ")) Accounts.append( bank.Account(type, currency, name, surname, address, doc_type, doc_num, number)) sort.insertion_sort(Accounts) elif flag == 2: acc_number = int(input("Insert the account number: ")) acc = search.search(Accounts, acc_number) if acc == -1: print("The account does not exist") else: Accounts[acc].show_info() print( "Are you sure you want to delete this account? Press 1 to confirm, any other key to cancel" ) dele = int(input()) if dele == 1: del Accounts[acc] print(bank.Account.Count) else: print("Deletion cancelled") elif flag == 3: acc_number = int(input("Insert the account number: ")) acc = search.search(Accounts, acc_number) if acc == None: print("The account does not exist") else: Accounts[acc].show_info() elif flag == 4: acc_number = int(input("Insert the account number: ")) acc = search.search(Accounts, acc_number) if acc == -1: print("The account does not exist") else: print("Available balance: ", Accounts[acc].balance, " ", Accounts[acc].currency) amount = int(input("Amount to withdraw?")) Accounts[acc].withdraw(amount) elif flag == 5: acc_number = int(input("Insert the account number: ")) acc = search.search(Accounts, acc_number) if acc == -1: print("The account does not exist") else: print("Available balance: ", Accounts[acc].balance, " ", Accounts[acc].currency) amount = int(input("Amount to deposit?")) curr = input("currency?") Accounts[acc].deposit(amount, curr) elif flag == 6: pass #I can add the options to modify the various parts of the account # informations but that is just a series of if-elif...-else # and inputs so I'm just too lazy to do it elif flag == 7: acc_number = int(input("Insert the sender's account number: ")) acc1 = search.search(Accounts, acc_number) if acc1 == -1: print("The account does not exist") else: acc_number = int( input("Insert the receiver's account number: ")) acc2 = search.search(Accounts, acc_number) if acc2 == -1: print("The account does not exist") else: amount = int( input("How much money from the sender's account?")) bank.transfer(Accounts[acc1], Accounts[acc2], amount) elif flag == 8: print("Account number, name, surname") for i in range(0, len(Accounts)): print(Accounts[i].number, " ", Accounts[i].owner.name, " ", Accounts[i].owner.surname) elif flag == 9: save_data() print("Bye Bye!") else: print("Wrong input. Please try again")
import bank client_1 = bank.Client('Rodrigo', 'Bernardo', '111484867-04') account_1 = bank.Account('123-4', client_1, 250.0, 1500.0) client_2 = bank.Client('Renata', 'Teixeira', '120132167-00') account_2 = bank.Account('123-4', client_2, 250.0, 1500.0) account_3 = bank.Account('123-4', client_2, 250.0, 1500.0) account_4 = bank.Account('123-4', client_2, 250.0, 1500.0) account_5 = bank.Account('123-4', client_2, 250.0, 1500.0) account_6 = bank.Account('123-4', client_2, 250.0, 1500.0) print(account_1.id) print(account_2.id) print(account_3.id) print(account_4.id) print(account_5.id) print(account_6.id)
import bank import tree # test Binary Search Tree class testTree = tree.BinarySearchTree() testTree[16] = "test" testTree[166] = "dog" testTree[54] = "car" print(testTree.isEmpty()) print(testTree.find(16)) # test the account class testAccount = bank.Account("Katie", "Danvers", 1206) testAccount2 = bank.Account("Steve", "Banner", 1234) # test the transaction class # test the fund class
#C:Python31python.exe # -*- coding:utf-8 -*- import bank acct = bank.Account('Pingyao', '999-9999', 10000000) acct.deposit(500) acct.withdraw(200) print acct.balance
# b.deposit(500) # print(b.number) # print(b.total) # print() # print('----- SAQUE -------') # print() # b.withdraw(200) # print(b.number) # print(b.total) # # print('----- EXTRATO -------') # print() # print(b.get_total()) # COM MODIFICADORES DE ACESSO c1 = bank.Account('123-12') c1.deposit(250) c1.withdraw(200) print(c1.get_total()) # DETALHAMENTO DA CLASSE print(type(c1)) print(c1.__class__) # HERANÇA c2 = bank.Account2('321-21', 123) c2.deposit(250) c2.withdraw(200) print(c2.get_cvv()) print(c2.get_total())