Ejemplo n.º 1
0
class BankAcount(unittest.TestCase):

    def setUp(self):
        self.ba = BankAccount("rado", 500, "$")

    def tearDown(self):
        pass

    def tets_create_new_BankAccount_class(self):
        self.assertEqual(self.ba.history(),"Account was created")
        self.assertTrue(isinstance(self.ba, BankAccount))

    def test_create_int_value_from_BankAccount(self):
        self.assertEqual(int(self.ba), 500)
    def test__str__in_BankAccount(self):
        self.assertEqual(str(self.ba),"Bank account for rado with balance of 500$")
    def test_balance(self):
        self.assertEqual(self.ba.balance(),500)
    def test_transfer_to(self):
        maria = BankAccount("Maria",200,"$")
        self.assertEqual(self.ba.transfer_to(maria,"$"),True)
        with self.assertRaises(TypeError) :
            self.ba.transfer_to("maria","$")
    def test_withdraw(self):
        self.assertTrue(self.ba.withdraw(200))
        self.assertFalse(self.ba.withdraw(900))
    def test_deposit(self):
        d = 1000
        self.ba.deposit(500)
        self.assertEqual(self.ba.balance(),1000)
class BankAccountTest(unittest.TestCase):

    def setUp(self):
        self.acc_name = "Ivan"
        self.acc_balance = 200
        self.acc_curr = "$"

        self.bank_acc = BankAccount(self.acc_name, self.acc_balance, self.acc_curr)
        self.test_dep_value = 1000
        self.test_str_dun = "Bank account for Ivan with balance of 200$"
        self.test_hist_str = ['Account was created', 'Deposited 1000$', 'Balance check -> 1200$', \
'__int__ check -> 1200$']

    def test_create_new_bank_instance(self):
        self.assertTrue(isinstance(self.bank_acc, BankAccount))

    def test_method_deposit(self):
        new_balance = self.bank_acc.balance() + self.test_dep_value
        self.bank_acc.deposit(self.test_dep_value)

        self.assertEqual(new_balance, self.bank_acc.balance())

    def test_method_balance(self):
        self.assertEqual(self.bank_acc.balance(), self.acc_balance)

    def test_str_dunder(self):
        self.assertEqual(self.test_str_dun, str(self.bank_acc))

    def test_history(self):
        self.bank_acc.deposit(self.test_dep_value)
        self.bank_acc.balance()
        int(self.bank_acc)
        self.assertEqual(self.bank_acc.history(), self.test_hist_str)
Ejemplo n.º 3
0
class AccountBalanceTestCases(unittest.TestCase):
    def setUp(self):
        self.my_account = BankAccount(90)

    def test_balance(self):
        self.assertEqual(self.my_account.balance,
                         90,
                         msg='Account Balance Invalid')

    def test_deposit(self):
        self.my_account.deposit(90)
        self.assertEqual(self.my_account.balance,
                         180,
                         msg='Deposit method inaccurate')

    def test_withdraw(self):
        self.my_account.withdraw(40)
        self.assertEqual(self.my_account.balance,
                         50,
                         msg='Withdraw method inaccurate')

    def test_invalid_operation(self):
        self.assertEqual(self.my_account.withdraw(1000),
                         "invalid transaction",
                         msg='Invalid transaction')

    def test_sub_class(self):
        self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount),
                        msg='No true subclass of BankAccount')
Ejemplo n.º 4
0
    def test_deposit(self):
        dep_1 = BankAccount("gigi").deposit(2000)
        dep_2 = BankAccount("gigi").deposit(3000)
        dep_3 = BankAccount("gigi").deposit(-6000)

        self.assertEqual(dep_1, "The amount you want to deposit is $2000.00")
        self.assertEqual(dep_2, "The amount you want to deposit is $3000.00")
        self.assertEqual(dep_3, "The amount you entered is incorrect!")
Ejemplo n.º 5
0
 def test_withdraw(self):
     widraw_1 = BankAccount("gigi").withdraw(1000)
     widraw_2 = BankAccount("gigi").withdraw(3000)
     self.assertEqual(
         widraw_1,
         "The amount of $1000.00 had been withdrawed from your account! \n"
         "Your Balance is $1000.00")
     self.assertEqual(widraw_2,
                      "The amount you entered is grater than the balance!")
     with self.assertRaises(ValueError):
         BankAccount("gigi").withdraw(-6000)
Ejemplo n.º 6
0
 def setUp(self):
     self.name = "Rado"
     self.amount = 0
     self.currency = '$'
     self.my_account = BankAccount(self.name, self.amount, self.currency)
     self.deposited_money = 1000
     self.deposited_money_negative = -1000
     self.withdrawed_money_true = 500
     self.withdrawed_money_false = 1000
     self.transfered_money_true = 500
     self.transfered_money_false = 2000
Ejemplo n.º 7
0
 def __init__(self,db_file):
     ''' (Bank,str)-> NoneType
     initialize the Bank database from a file given as argument
     '''
     self._database = set()
     handle = open(db_file,"r")
     lines = handle.readlines()
     for line in lines:
         data = line.split(",")
         p = Person(data[0],data[1],data[2])
         a = BankAccount(p)
         a.credit(int(data[3]))
         self._database.add(a)
Ejemplo n.º 8
0
class TestBankAccount(unittest.TestCase):  # test case
    """
    Unit Test for the BankAccount Class
    """
    def setUp(self):  # test fixture
        # print('setup called')
        self.ing = BankAccount('mila', 500)
        self.bnp = BankAccount('alex', 2000)

    def test_deposit(self):
        """ testing the deposit method """
        self.ing.deposit(200)
        self.bnp.deposit(500)

        self.assertEqual(self.ing.balance, 700)
        self.assertEqual(self.bnp.balance, 2500)

    def test_withdraw(self):
        """ testing the withdraw method """
        self.ing.withdraw(400)
        self.bnp.withdraw(1200)

        self.assertEqual(self.ing.balance, 100)
        self.assertEqual(self.bnp.balance, 800)

        self.assertRaises(ValueError, self.ing.withdraw, 500)
Ejemplo n.º 9
0
class User:  # here's what we have so far
    def __init__(self, name, email):
        self.name = name
        self.email = email
        self.account = BankAccount(4.0)

    # adding the deposit method
    def make_deposit(
            self,
            amount):  # takes an argument that is the amount of the deposit
        self.account.deposit(amount)
        return self

    def make_withdrawl(self, amount):
        self.account.withdraw(amount)
        return self

    def display_user_balance(self):
        self.account.display_account_info()
        return self

    def transfer_money(self, other_user, amount):
        other_user.account.deposit(amount)
        self.account.withdraw(amount)
        return self
Ejemplo n.º 10
0
 def createBankAccount(self, name, acctType, balance=0):
     accountNum = self.__getNextAccountNum()
     if accountNum in self.__bankAccounts:
         return DUPLICATE_NUMBER
     newBankAccount = BankAccount(accountNum, name, acctType, name)
     self.__bankAccounts[accountNum] = newBankAccount
     return accountNum
Ejemplo n.º 11
0
    def load_records(database_file):
        """\
        Opens the specified local database file with the bank account records and store the
        records in-memory for usage with the aid of the dictionary data structure.

        Checks that the argument 'database_file' passed in is of type 'str' else an 'Exception' is raised.

        If the specified database file doesn't exist an 'Exception' is raised.

        :param database_file: Name of the database file to load records from
        :return: Dictionary data structure with the bank account records
        """
        if type(database_file) != str:
            raise Exception(
                "Invalid argument: database_file of type {} should be: <class 'str'>"
                .format(type(database_file)))
        database = DatabaseConnection(database_file)
        records = dict()
        result_set = database.sql_statement(database.READ,
                                            "SELECT * FROM accounts")
        for record in result_set:  # grab each record from the result-set
            records[record[4]] = BankAccount(record[0], record[1], record[2],
                                             record[3])
        database.close()
        return records
Ejemplo n.º 12
0
 def test_transfer_to(self):
     self.my_account.amount = 1000
     # CHECK CURRENCY
     ivo = BankAccount("Ivo", 0, "BGN")
     self.assertFalse(self.my_account.transfer_to(ivo, 600))
     ivo.currency = '$'
     # CHECK IF MONEY IS ENOUGH
     self.assertFalse(
         self.my_account.transfer_to(ivo, self.transfered_money_false))
     self.assertTrue(
         self.my_account.transfer_to(ivo, self.transfered_money_true))
     # CHECK IF MONEY HAS CHANGED, TRANSFERED
     ivo.amount = 0
     self.my_account.amount = 1000
     self.my_account.transfer_to(ivo, 200)
     self.assertEqual(self.my_account.balance(), 800)
     self.assertEqual(ivo.balance(), 200)
Ejemplo n.º 13
0
 def create_account(self, first_name: str, last_name: str,
                    initial_deposit: float, preferred_tz) -> BankAccount:
     self._last_account_number += 1
     new_account = BankAccount(first_name, last_name,
                               self._last_account_number, initial_deposit,
                               preferred_tz)
     self._active_accounts.append(new_account)
     return new_account
class User:
    def __init__(self, name, email):
        self.name = name
        self.email = email
        self.account = BankAccount()

    def deposit(self, amount):
    	self.account.deposit(amount)
    def make_withdrawal(self, amount):
    	return self.account.withdraw(amount)
    def display_user_balance(self):
        self.account.display_account_info()
        print(f"{self.name} balance is:{self.balance}")
    def transfer_money(self,other_user,amount):
        if self.withdrawal(amount):
            other_user.deposit(amount)
            return True
        return False     
    def setUp(self):
        self.acc_name = "Ivan"
        self.acc_balance = 200
        self.acc_curr = "$"

        self.bank_acc = BankAccount(self.acc_name, self.acc_balance, self.acc_curr)
        self.test_dep_value = 1000
        self.test_str_dun = "Bank account for Ivan with balance of 200$"
        self.test_hist_str = ['Account was created', 'Deposited 1000$', 'Balance check -> 1200$', \
'__int__ check -> 1200$']
Ejemplo n.º 16
0
class user:
    def _int_(self, name, year_of_birth, balance=0):
        self.name = name
        self.year_of_birth = year_of_birth
        self.account = BankAccount()

    def make_withdrawal(self, amount):
        return self.account.withdraw(amount)

    def display_user_balance(self):
        print(f"{self.name} Balance is:", end=" ")

    def deposit(self, amount):
        self.account.deposit(amount)

    def transfer_money(self, other_user, amount):
        if self.make_withdrawal(amount):
            other_user.deposit(amount)
            return True
        return False
Ejemplo n.º 17
0
def bankAccountCreate(bankAccount):
    b = bankAccount
    dbAcnt = BankAccount(name=b['name'],
                         description=b['description'],
                         bankName=b['bankName'],
                         ifscCode=b['ifscCode'],
                         accountNumber=b['accountNumber'],
                         interestRate=b['interestRate'],
                         mab=b['mab']).save()

    print("BankAccount", colored(dbAcnt.name), "created")
Ejemplo n.º 18
0
def create_account(user_name, initial_deposit, password):
    """
    :param user_name: User name to create a Bank Account for
    :param initial_deposit: The initial amount user wants to deposit into account
    :return: None
    """
    bank_acc = BankAccount(user_name, initial_deposit, password)
    accounts[user_name] = bank_acc

    print("\nThank you! Here is your Bank info: ")
    print("Name: {}".format(bank_acc.name.title()))
    print("Acccount Number: {}".format(bank_acc.accnum))
    print("Balance: ${:.2f}\n\n".format(int(bank_acc.balance)))
Ejemplo n.º 19
0
 def test_history(self):
     # Account Creation
     self.assertEqual(self.my_account.history()[0], 'Account was created')
     # Deposit
     self.my_account.deposit(1000)
     trueString = 'Deposited 1000' + self.my_account.currency
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Balance
     self.my_account.balance()
     trueString = 'Balance check -> ' + \
         str(self.my_account.balance()) + self.my_account.currency
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Int transformation
     trueString = '__int__ check -> ' + \
         str(self.my_account.balance()) + self.my_account.currency
     int(self.my_account)
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Successfull withdraw
     self.my_account.withdraw(500)
     trueString = '500' + self.my_account.currency + \
         ' was withdrawed'
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Failed withdraw
     self.my_account.withdraw(1000)
     trueString = 'Withdraw for {}{} failed.'.format(
         1000, self.my_account.currency)
     self.assertEqual(self.my_account.history()[-1], trueString)
     # Transfer
     ivo = BankAccount("Ivo", 0, "$")
     self.my_account = BankAccount("Rado", 1000, "$")
     self.my_account.transfer_to(ivo, 500)
     trueString_Rado = 'Transfer to {} for {}{}'.format(
         ivo.name, 500, self.my_account.currency)
     trueString_Ivo = 'Transer from {} for {}{}'.format(
         self.my_account.name, 500, ivo.currency)
     self.assertEqual(self.my_account.history()[-1], trueString_Rado)
     self.assertEqual(ivo.history()[-1], trueString_Ivo)
Ejemplo n.º 20
0
def main():
    populate_database()
    while True:
        try:
            # To Test please use 123,5678 or 6788
            customer_id = input(
                "Please enter customer ID, Use Cust_id=123 or 5678 or 6788: ")
            if not customer_id:
                break
            choice = int(input("Please enter 1-Deposit or 2-Withdraw: "))
            if choice == 1:
                b = BankAccount(cust_id=customer_id)
                amt = int(input("Please enter the amount to deposit: "))
                b.deposit(cust_id=customer_id, amount=amt)

            elif choice == 2:
                b = BankAccount(cust_id=customer_id)
                amt = int(input("Please enter the amount to withdraw: "))
                b.withdraw(cust_id=customer_id, amount=amt)
        except ValueError:
            print("Oops!  Invalid values  Try again...")
Ejemplo n.º 21
0
def _account_selection(account_names, accounts):
    choice = raw_input('Welcome to the Family Banking App. Who is this?')
    if choice not in account_names:
        print(
            'This person does not have an account. The people with accounts are: '
            + ', '.join(account_names) + '.')
        new_account = _request_user_input(
            'Do you wish to make an account for ' + choice + '? (Y/N)',
            ['Y', 'N'], 'Invalid response. Try again.')
        if new_account == 'Y':
            amount_to_deposit = raw_input(
                'How much would you like to deposit in this (' + choice +
                '\'s) account?')
            accounts.append(BankAccount(choice, float(amount_to_deposit)))
            account_names.append(choice)
            return choice
        else:
            print('Try again, then. Who is this?')
            choice = _account_selection(account_names, accounts)
        return choice
    return choice
Ejemplo n.º 22
0
 def parse_text_file(self, text_file):
     bank_account = BankAccount()
     for row_index, row in enumerate(text_file):
         if (row_index + 1) % 4 == 0:
             self.accounts.append(bank_account)
             bank_account = BankAccount()
         else:
             strip_row = row.rstrip()
             for digit_index, index in enumerate(range(
                     0, len(strip_row), 3)):
                 value = list(strip_row[index:index + 3])
                 if len(value) < 3:
                     value.append(' ')
                 bank_account.set_row(digit_index=digit_index,
                                      row_index=row_index % 4,
                                      value=value)
Ejemplo n.º 23
0
class user:
    def __init__(self, name, email):
        self.name = name
        self.email = email
        self.account = BankAccount()

    def make_deposite(self, amount):
        self.account.deposit(amount)

    def make_withdrawal(self, amount=0):
        self.account.withdraw(amount)

    def display_user_balance(self):
        print("User Name: " + self.name + ", User Balance: ", end=" ")
        self.account.display_account_info()

    def transfer_money(self, other_user, amount):
        if self.make_withdrawal(amount):
            other_user.make_deposite(amount)
            return True
        return False
Ejemplo n.º 24
0
 def add_account(self, customer_id, name, init_balance):
     self.account_list.append(BankAccount(customer_id, name, init_balance))
Ejemplo n.º 25
0
def populate_database():
    """Populate the database."""
    emp = Employees(123456, 'Sammy', 'Retail Applications', 'IT Analyst')
    emp1 = Employees(5678, 'Nancy', 'Capital Market', 'Teller')
    emp.create_employees()
    emp1.create_employees()

    cust = Customer(123, 'John', '*****@*****.**', '1-233-2234')
    cust1 = Customer(5678, 'Katherine', '*****@*****.**', '1-456-4578')
    cust2 = Customer(6788, 'Vijay', '*****@*****.**', '1-678-5555')
    cust.create_customer()
    cust1.create_customer()
    cust2.create_customer()

    bank_Acc = BankAccount(1234444, 123, 'Chequing', 100)
    bank_Acc.create_Bank_Account()

    bank_Acc1 = BankAccount(567888, 5678, 'Saving', 200)
    bank_Acc1.create_Bank_Account()

    bank_Acc2 = BankAccount(1677777, 6788, 'Chequing', 400)
    bank_Acc2.create_Bank_Account()

    creditCard = CreditCard('Ms', 'Nancy', 'Smith', '15 Bloor St, Toronto',
                            14566666, 'May', 2023, '677', 'Visa', 'CAD')
    creditCard.create_Credit_Account()
    creditCard1 = CreditCard('Mr', 'Sam', 'Rogers', '15 Upland St, Toronto',
                             8999666, 'Aug', 2021, '127', 'Visa', 'CAD')
    creditCard1.create_Credit_Account()
Ejemplo n.º 26
0
from BankEmpire import BankEmpire
from Bank import Bank
from Customer import Customer
from HighNetWorthCustomer import HighNetWorthCustomer
from BankAccount import BankAccount
from datetime import datetime as dt

ianbotzEmpire = BankEmpire('The Ianbotz Bank Empire')
'''''' '''''' '''''' '''''' '''''' '''''' ''''''
iBank1 = Bank('Lavender Side Bank')

georgeCustomer = Customer('George Curious', 23, 60_000,
                          BankAccount(balance=130))
stevenCustomer = HighNetWorthCustomer('Steven Hillborough', 78, 3_200_000,
                                      BankAccount(balance=36_000_000),
                                      'Exchange Traded Funds', dt(1942, 3, 26))

iBank1.addCustomer(georgeCustomer)
iBank1.addCustomer(stevenCustomer)

ianbotzEmpire.addBank(iBank1)
'''''' '''''' '''''' '''''' '''''' '''''' ''''''
iBank2 = Bank('Mason Hill Bank')

williamCustomer = Customer('William Blake', 18, 40_000,
                           BankAccount(balance=200))
joshCustomer = Customer('Josh Maven', 35, 80_000, BankAccount(balance=30_000))
ronaldCustomer = HighNetWorthCustomer('Ronald McDonald', 68, 128_200_000,
                                      BankAccount(balance=1_200_000_000),
                                      'Foreign Exchange Market',
                                      dt(1950, 8, 2))
Ejemplo n.º 27
0
 def setUp(self):
     self.my_account = BankAccount(90)
 def __init__(self, name, email):
     self.name = name
     self.email = email
     self.account = BankAccount()
Ejemplo n.º 29
0
# Test driver for BankAccount, JointBankAccount, and
# CreditBankAccount classes
#########################################################

# A sample comment.  All comments start with #.

# Importing the classes we will use
# Format is: from <file name without .py> import <class name>
from BankAccount import BankAccount
from JointBankAccount import JointBankAccount
from CreditBankAccount import CreditBankAccount


# Create a BankAccount object and do a few transactions
# Notice "try/except" statement to handle exceptions raised
basicAccount = BankAccount("Sam Smith", 0)
print("At creation      : " + basicAccount.toString())

basicAccount.deposit(100)
print("After deposit 100: " + basicAccount.toString())

basicAccount.withdraw(50)
print("After withdraw 50: " + basicAccount.toString())

try:
    basicAccount.withdraw(75)
    print("After withdraw 75: " + basicAccount.toString())
except Exception as ex:
    print("Failed to withdraw 75: " + str(ex))

Ejemplo n.º 30
0
        else:
            print('out of stock')

    @property
    def price(self):
        return self._price

    @price.setter
    def price(self, x):
        if 50 < x < 1000:
            self._price = x
        else:
            raise ValueError('asdasd')


a = BankAccount('fayed', 200)
a.display()
book1 = Book('957-4-36-547417-1', 'Learn Physics', 'Stephen', 'CBC', 350, 200,
             10)
book2 = Book('652-6-86-748413-3', 'Learn Chemistry', 'Jack', 'CBC', 400, 220,
             20)
book3 = Book('957-7-39-347216-2', 'Learn Maths', 'John', 'XYZ', 500, 300, 5)
book4 = Book('957-7-39-347216-2', 'Learn Biology', 'Jack', 'XYZ', 400, 200, 6)
book1.display()
book1.sell()
books = [book1, book2, book3, book4]
for i in range(4):
    books[i].display()
book_title_list = [books[i].title for i in range(4)]
print(book_title_list)
a = Fraction(-2)
Ejemplo n.º 31
0
# Class: 1321L
# Sec: 02
# Lab: Python
# Term: Fall 2018
# Instructor: Malcolm
# Name: Ly Pham

from BankAccount import BankAccount

myObject = BankAccount()
myObject.setID(123456)
myObject.setbalance(10000)
myObject.withdraw(3500)
myObject.deposit(500)
myObject.setannualInterestRate(2.50)
print(myObject.toString())

Ejemplo n.º 32
0
from AccountException import AccountException
from Bank import Bank
from BankAccount import BankAccount
from BankAccount_INT import BankAccount_INT
from BankAccount_COVID19 import BankAccount_COVID19
from BankAccount_COVID19_company import BankAccount_COVID19_company

bank = Bank()
pl_01 = BankAccount('PL_01', 10000)
int_01 = BankAccount_INT('INT_01', 10000)
covid_01 = BankAccount_COVID19('COVID_01', 10000)
company_01 = BankAccount_COVID19_company('COMPANY_01', 10000)

for account in [pl_01, int_01, covid_01, company_01]:
  bank.add(account)
 
print(bank)

# BankAccount
print()
pl_01.deposit(200)
pl_01.withdraw(300)
print(pl_01)

try:
  pl_01.withdraw(50000)
except AccountException as e:
  print('Error:', e)

print()
print(pl_01)
Ejemplo n.º 33
0
from BankAccount import BankAccount

# Create a new instance of BankAccount
newAccount = BankAccount()
# open a new file
bankFile = open("AccountSummary_AlanVenneman.txt", "w")
bankFile.write("### Welcome to Acme Bank ###\n")
# Ask user for initial deposit
newAccount.setBalance(eval(input("Enter opening balance: ")))
bankFile.write("Opening balance for February: ${:.2f}\n".format(
    newAccount.getBalance()))
# Ask user for additional deposits
deposits = 0.0
print("Enter deposits first, type the number 0 after final entry.")
while (deposits != -1):
    deposits = newAccount.setDeposit(float(input("Enter deposit: ")))
    if (deposits != -1):
        bankFile.write(str(deposits) + '\n')
    else:
        bankFile.write("Your Deposits: ${:.2f}\n".format(
            newAccount.getDeposit()))
# Ask user for a withdrawal
withdrawals = 0
print("Enter withdrawals second, type the number 0 after final entry.")
while withdrawals > -1:
    withdrawals = newAccount.setWithdraw(float(input("Enter withdrawal: ")))
    if withdrawals != -1:
        bankFile.write("Your Withdrawals: ${:.2f}\n".format(
            newAccount.getWithdraw()))
# Print closing Amount
bankFile.write("Your final balance today is: ${:.2f}\n".format(
Ejemplo n.º 34
0
 def setUp(self):
     self.account = BankAccount("Vladko", 2000, "RON")
     self.account1 = BankAccount("Phillip", 4114, "RON")
Ejemplo n.º 35
0
class TestBankAccount(unittest.TestCase):
    def setUp(self):
        self.account = BankAccount("Vladko", 2000, "RON")
        self.account1 = BankAccount("Phillip", 4114, "RON")

    def test_init(self):
        self.assertEqual(self.account.get_name(), "Vladko")
        self.assertEqual(self.account1.get_name(), "Phillip")
        self.assertEqual(self.account.get_currency(), "RON")
        self.assertTrue(self.account.get_currency() == self.account1.get_currency())

    def test_str(self):
        self.assertEqual(str(self.account), "Bank account for Vladko with balance of 2000 RON")
        self.assertEqual(str(self.account1), "Bank account for Phillip with balance of 4114 RON")

    def test_get_name(self):
        self.assertEqual(self.account.get_name(), "Vladko")

    def test_get_currency(self):
        self.assertEqual(self.account1.get_currency(), "RON")

    def test_int(self):
        self.assertEqual(int(self.account), 2000)
        self.assertEqual(int(self.account1), 4114)

    def test_history(self):
        self.assertEqual(self.account.history(), ['Account was created.'])

    def test_deposit(self):
        self.account.deposit(213)
        self.assertEqual(int(self.account), 2213)
        self.account1.deposit(400)
        self.assertEqual(int(self.account1), 4514)

    def test_balance(self):
        self.assertEqual(self.account.balance(), 2000)

    def test_withdraw(self):
        self.account.withdraw(1200)
        self.assertEqual(self.account.balance(), 800)
        self.account1.withdraw(10000)
        self.assertEqual(self.account1.balance(), 4114)

    def test_transfer(self):
        self.account1.transfer_to(self.account, 114)
        self.assertEqual(int(self.account), 2114)
        self.assertEqual(int(self.account1), 4000)

    def test_history(self):
        self.assertEqual(self.account.history(), ['Account was created.'])
Ejemplo n.º 36
0
 def setUp(self):
     self.ba = BankAccount("rado", 500, "$")
Ejemplo n.º 37
0
from BankAccount import BankAccount
# ||===========================================||
# ||             Main Function                 ||
# ||===========================================||

# user input of their current balance
currentBalance = float(input('Enter your current Balance:'))

# initializing the bank account with the courrent balance
my_account = BankAccount(currentBalance)

# if the initial balance is nonzero
if float(my_account.balance) > 0.00:

    # Option for user to select what they want to do
    print(' OPTIONS:\n'
          '1. Check Balance \n'
          '2. Deposit \n'
          '3. Withdraw \n'
          '4. Spend \n')
    choice = input("what is your choice from the above options: ")
    print("you chose OPTION #: ", choice)

    # User chooses to view balance
    if choice is '1':

        # prints the current balance of the Account
        print("You have: $", my_account.balance, "in your bank Account")

        # end the transaction or keep going
        keepGo = input("Are you done with your transaction?:\n"