def test_opening_balance(self): account = BankAccount(balance=100) self.assertEqual(account.balance, 100)
def test_deposit(self): account1 = BankAccount() account1.deposit(3400) self.assertEqual(account1.account_balance, 3900)
def test_invalid_transaction(self): account1 = BankAccount() self.assertEqual(account1.withdraw(1000), "Your account balance is insufficient")
def test_close_already_closed_account(self): account = BankAccount() with self.assertRaisesWithMessage(ValueError): account.close()
def setUp(self): self.account1 = BankAccount('Ivo', 0, 'BGN') self.account2 = BankAccount('Rado', 1000, 'BGN')
def _create_default_account(self): self.accounts = {"primary": BankAccount(int_rate=0.02, balance=0)}
def test_newly_opened_account_has_zero_balance(self): account = BankAccount() account.open() self.assertEqual(account.get_balance(), 0)
def setUp(self): self.account = BankAccount("Rado", 1000, "$")
from bank_account import BankAccount # accounts account1 = BankAccount('John', 'Doe') account2 = BankAccount('Jane', 'Doe') account3 = BankAccount('Test', 'User') #account1.deposit(1000) account3.deposit(2000) print(account3.account_detail) account3.withdraw(1000) #print(account1.account_detail) #print() print(account3.account_detail) print() print('Total accounts: {}'.format(BankAccount.accounts))
def test_new_account_balance_default(self): account = BankAccount() self.assertEqual(account.balance, 0)
__author__ = 'vikram' from bank_account import BankAccount account = BankAccount() account.deposit(40) print(account) def exclude(pred_func, full_list): exc_list = [] for n in full_list: if not pred_func(n): exc_list.append(n) return exc_list print exclude(lambda x: len(x) > 3, ["red", "blue", "green"]) print exclude(bool, [False, True, False]) def call(some_func, *args): print args return some_func(*args) print call(int) print call(len, "hello")
def test_transfer(self): mary_account = BankAccount(balance=100) dana_account = BankAccount(balance=0) mary_account.transfer(dana_account, 20) self.assertEqual(mary_account.balance, 80) self.assertEqual(dana_account.balance, 20)
def test_withdraw(self): account = BankAccount(balance=100) account.withdraw(40) self.assertEqual(account.balance, 60)
def test_deposit(self): account = BankAccount() account.deposit(100) self.assertEqual(account.balance, 100)
def set_up(self): self.account = BankAccount() self.printed_text = ''
def test_close_already_closed_account(self): account = BankAccount() with self.assertRaises(ValueError) as err: account.close() self.assertEqual(type(err.exception), ValueError) self.assertEqual(err.exception.args[0], "account not open")
def add_account(self, account_name, int_rate, balance): self.append({account_name: BankAccount(int_rate=int_rate, balance=balance)}) return self
def __init__(self, username, email_address): self.name = username self.email = email_address self.account = BankAccount(0.02, 0)
def test_cannot_deposit_negative(self): account = BankAccount() account.open() with self.assertRaisesWithMessage(ValueError): account.deposit(-50)
from bank_account import BankAccount, SpecialBankAccount from employee import Employee if __name__ == '__main__': ba = BankAccount('ING', 100) print(ba.bank_name) print(ba.balance) ba.deposit(100) ba.withdraw(150) print(ba.balance) try: ba.withdraw(100) except Exception as ex: print(ex) print(ba.balance) e = Employee('Alin', ba) print(e.name.upper()) print(e.bank_account.balance) print(e.salary) e.salary = 800 print(e.salary) e.receive_salary() print(e.bank_account.balance) sba = SpecialBankAccount('BCR', 100, 200)
def test_can_deposit_money(self): account = BankAccount() account.open() account.deposit(100) self.assertEqual(account.get_balance(), 100)
def setUp(self): self.account_yangu = BankAccount()
def test_open_already_opened_account(self): account = BankAccount() account.open() with self.assertRaisesWithMessage(ValueError): account.open()
from bank_account import BankAccount main_account = BankAccount("DE123", "Marko") savings_account = BankAccount("DE4432", "Marko") main_account.booking(2000, "€", "Salary") main_account.booking(-15.50, "€", "Amazon Book") print( f"Owner: {main_account.owner_name}, IBAN: {main_account.iban}, Bookings: {main_account.bookings}" ) print(f"Balance: {main_account.get_balance()}")
def test_balance(self): account1 = BankAccount() self.assertEqual(account1.account_balance, 500)
@property def phone(self) -> str: return self._phone @phone.setter def phone(self, phone: str): self._phone = phone if __name__ == "__main__": p1 = Person("Jake Kelly", "*****@*****.**", "12341234") p2 = Person("Cooper Kelly", "*****@*****.**", "34563456") p3 = Person("Sally Kelly", "*****@*****.**", "56785678") acc1 = BankAccount() acc2 = BankAccount() acc1.transactions.append(100) acc1.transactions.append(100) acc1.transactions.append(-50) print(sum(acc1.transactions)) acc2.transactions.append(200) acc2.transactions.append(500) acc2.transactions.append(-50) # for p in [p1, p2, p3]: # print(f"{p.name}, {p.phone} {p.email}") # p2.email = "*****@*****.**"
def test_withdraw(self): account1 = BankAccount() account1.withdraw(100) self.assertEqual(account1.account_balance, 400)
def setUp(self): self.my_account = BankAccount()
def test_sub_class(self): account1 = BankAccount() self.assertTrue(issubclass(LeastBalance, BankAccount))
def test_can_withdraw_money(self): account = BankAccount() account.open() account.deposit(100) account.withdraw(50) self.assertEqual(account.get_balance(), 50)