コード例 #1
0
 def test_transfer(self):
     g = Client(cash=100)
     c = Client(cash=200)
     b = Bank()
     b.register(g)
     b.register(c)
     b.deposit(g, 100)
     b.deposit(c, 200)
     b.transfer(g, b, c, 100)
     self.assertEqual(b.checkbalance(c), 300)
コード例 #2
0
def main():
    print("Creating bank")
    bank = Bank()
    print("Creating account")
    bank.create_account("bill gates", "msft", 100)
    print("Checking balance, wrong account")
    result = bank.check_balance("jeff bezos", "amzn")
    print(result)
    print("Checking balance, wrong password")
    result = bank.check_balance("bill gates", "amzn")
    print(result)
    print("Checking balance")
    result = bank.check_balance("bill gates", "msft")
    print(result)
    print("Depositing money")
    result = bank.deposit("bill gates", "msft", 10)
    print(result)
    print("Withdrawing money")
    result = bank.withdraw("bill gates", "msft", 15)
    print(result)
    print("Trying to withdraw too much")
    result = bank.withdraw("bill gates", "msft", 1000)
    print(result)
コード例 #3
0
 def test_deposit3(self):
     g = Client(cash=100)
     b = Bank()
     b.register(g)
     self.assertFalse(b.deposit(g, 101))
コード例 #4
0
 def test_deposit(self):
     g = Client(cash=500)
     b = Bank()
     self.assertFalse(b.deposit(g, 100))
コード例 #5
0
 def test_deposit2(self):
     g = Client(cash=100)
     b = Bank()
     b.register(g)
     self.assertTrue(b.deposit(g, 100))
コード例 #6
0
 def test_unregistered(self):
     g = Client()
     b = Bank()
     self.assertFalse(b.unregister(g))
コード例 #7
0
 def test_checkbalance(self):
     g = Client()
     b = Bank(clients=[g], accounts={g: 100})
     self.assertEqual(b.checkbalance(g), 100)
コード例 #8
0
 def test_register(self):
     g = Client()
     b = Bank()
     self.assertTrue(b.register(g))
     self.assertTrue(b.is_client(g))
コード例 #9
0
 def test_unregister(self):
     g = Client(cash=100)
     b = Bank(clients=[g], accounts={g: 200})
     self.assertEqual(b.unregister(g), 200)
コード例 #10
0
 def test_is_not_client(self):
     b = Bank()
     self.assertFalse(b.is_client("Goethe"))
コード例 #11
0
 def test_registered(self):
     g = Client(name="Goethe")
     b = Bank(name="Bank", clients=[g], accounts={g: 1})
     self.assertFalse(b.register(g))
コード例 #12
0
 def test_is_client(self):
     g = Client()
     b = Bank(name="Bank", clients=[g], accounts={g: 1})
     self.assertTrue(b.is_client(g))
コード例 #13
0
 def test_init_bank(self):
     g = Client()
     b = Bank(name="Bank", clients=[g], accounts={g: 1})
     self.assertTrue(g in b.clients)
コード例 #14
0
 def test_crossbanktransfer(self):
     g = Client(cash=400)
     c = Client()
     b = Bank()
     b2 = Bank()
     b.register(g)
     b2.register(c)
     b.deposit(g, 400)
     b.transfer(g, b2, c, 400)
     self.assertEqual(b2.checkbalance(c), 400)
コード例 #15
0
ファイル: test_banking.py プロジェクト: TheOneTAR/max-resnick
def test_account():
    test = Account(60, "tester")

    print("Try to add to much interest")
    test.interest(70)
    print("Attempt to over withdrawl account")
    test.withdrawl(70)
    test.withdrawl(60)
    print("Withdrawl almosteverything.", test.pretty_balance())
    test.deposit(60)
    print("New Balanmce should be 63:")
    print(test.pretty_balance())

def test_person():
    test = Person("max", "resnick", "*****@*****.**")
    print(test.open_account(500, "the test"))
    for account in test.accounts:
        print(account)
    print(test.close_account("the test"))
    print(test.close_account("the waka"))


from banking import Bank

test = Bank()

test.new_customer("max", "resnick", "*****@*****.**")

test.make_customer_account("*****@*****.**","test", 50)
Your new account has been succesfully created.
コード例 #16
0
def main():
    elliot = Client("Elliot", cash=1337)
    tyrell = Client("Tyrell", cash=64645435)
    allsafe = Client("Allsafe", cash=0)

    ebank = Bank(name="Evil Corp", clients=[tyrell], accounts={tyrell: 500})
    bbank = Bank(name="B2BB")

    ebank.register(elliot)
    bbank.register(allsafe)

    print(elliot)
    print(tyrell)
    print(allsafe)

    ebank.deposit(elliot, 1337)
    print("Elliot has ${} on his account (from deposit)".format(
        ebank.checkbalance(elliot)))
    print(elliot)

    ebank.deposit(tyrell, 500000)
    print("Tyrell has ${} on his account (from deposit and starting balance)".
          format(ebank.checkbalance(tyrell)))

    ebank.transfer(tyrell, bbank, allsafe, 500499)
    print("Allsafe's account balance: ${}".format(bbank.checkbalance(allsafe)))
    print("Tyrell after transfer: ${}".format(ebank.checkbalance(tyrell)))
    ebank.unregister(tyrell)
    print("Is Tyrell alive (as in a customer of the bank)? {}".format(
        ebank.is_client(tyrell)))