def main(): peer = Account('Peer', zit=8096, value=4) peer.transfer(16) bank = Bank() bank.add(peer) bank.transfer('Peer', 'Peer', 8) daddy = Account('Daddy', address='RLD 8', value=0) bank.add(daddy) bank.transfer('Peer', 'Daddy', 5)
def test_insufficient_funds_transfer(self): bank = Bank() bank.add( Account( 'Andrezinho', zip='12345-000', value=20.0, ref='21313213ac231de2131310128abd1231', )) bank.add( Account( 'Vadinho', zip='0000-000', vaue=450.0, ref='12313312cacb12122c1b12ac212b21', )) self.assertFalse(bank.transfer(1, 2, 1000.0))
def test_transfer(self): bank = Bank() bank.add( Account( 'Smith Jane', zip='911-745', value=1000.0, bref='1044618427ff2782f0bbece0abd05f31', )) bank.add( Account( 'William John', zip='100-064', value=6460.0, ref='58ba2b9954cd278eda8a84147ca73c87', info=None, other='This is the vice president of the corporation', )) self.assertFalse(bank.transfer('William John', 'Smith Jane', 545.0))
def test_fixing_corrupted_account(self): bank = Bank() # Jane account is corrupted because an attribute starts with 'b' jane = Account('Smith Jane', zip='911-745', value=1000.0, bref='1044618427ff2782f0bbece0abd05f31') william = Account( 'William John', zip='100-064', value=6460.0, ref='58ba2b9954cd278eda8a84147ca73c87', info=None, other='This is the vice president of the corporation') bank.add(jane) bank.add(william) # Accounts are added in Bank even if they are corrupted self.assertTrue(jane in bank.account) self.assertTrue(william in bank.account) # Check that Jane account is corrupted but not William's self.assertTrue(bank.is_account_corrupted('Smith Jane')) self.assertFalse(bank.is_account_corrupted('William John')) # Check that transfers fails when one of the account is corrupted self.assertFalse(bank.transfer('William John', 'Smith Jane', 545.0)) # Checks that fix_account function return True when account is corrupted and False otherwise self.assertTrue(bank.fix_account('Smith Jane')) self.assertFalse(bank.fix_account('William John')) # Checks that the corrupted element has been removed from Jane's account self.assertFalse('bref' in jane.__dict__.keys()) # Checks that transfer function now works with 2 uncorrupted accounts self.assertTrue(bank.transfer('William John', 'Smith Jane', 545.0)) # Check that the money has been added to Jane and retrieved from William self.assertTrue(jane.value == (1000.0 + 545.0)) self.assertTrue(william.value == (6460.0 - 545.0))
def test_fix_account(self): bank = Bank() bank.add( Account('Claumirzinho', zip='911-745', value=1000.0, bref='1044618427ff2782f0bbece0abd05f31')) bank.add( Account('Marquinhos Pato', zip='100-064', value=6460.0, ref='58ba2b9954cd278eda8a84147ca73c87', info=None)) self.assertFalse( bank.transfer('Marquinhos Pato', 'Claumirzinho', 1000.0)) bank.fix_account('Claumirzinho') bank.fix_account('Marquinhos Pato') self.assertTrue( bank.transfer('Marquinhos Pato', 'Claumirzinho', 1000.0))
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add( Account('Smith Jane', zip='911-745', value=1000.0, bref='1044618427ff2782f0bbece0abd05f31')) bank.add( Account('William John', zip='100-064', value=6460.0, ref='58ba2b9954cd278eda8a84147ca73c87', info=None, other='This is the vice president of the corporation')) # The transfer is supposed to fail because Jane account is corrupted if bank.transfer('William John', 'Smith Jane', 545.0) is False: print('Failed') else: print('Success')
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add(Account('Smith Jane', {'zip': '911-745', 'value': 1000.0})) bank.add(Account('William John', {'zip': '100-064', 'value': 6460.0, 'ref': '58ba2b9954cd278eda8a84147ca73c87', 'info': None, 'other': 'This is the vice president of the corporation'})) if bank.transfer('William John', 'Smith Jane', 545.0) is False: print('Failed') else: print('Success')
from the_bank import Bank, Account try: a = Account("graziella", a=20) b = Bank() b.add(a) except ValueError as err: print(err)
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add( Account( 'Smith Jane', **{ 'zip': '911-745', 'value': 1000.0, 'ref': '1044618427ff2782f0bbece0abd05f31' })) bank.add( Account( 'William John', **{ 'zip': '100-064', 'value': 6460.0, 'ref': '58ba2b9954cd278eda8a84147ca73c87', 'info': None, 'other': 'This is the vice president of the corporation' })) if bank.transfer('William John', 'Smith Jane', 5450.0) is False: print('Failed') else: print('Success')
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() newacc = Account('Charlie McG', 'bitebite') bank.add(newacc) if bank.transfer('Charlie McG', 'Charlie McG') is False: print("failed") else: print("success")
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add( Account('Smith Jane', zip='911-745', value=1000.0, ref='1044618427ff2782f0bbece0abd05f31')) bank.add( Account('William John', zip='100-064', value=6460.0, ref='58ba2b9954cd278eda8a84147ca73c87', info=None)) if bank.transfer('William John', 'Smith Jane', 1000.0) is False: print('Failed') bank.fix_account('William John') bank.fix_account('Smith Jane') if bank.transfer('William John', 'Smith Jane', 1000.0) is False: print('Failed') else: print('Success')
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add( Account( 'Smith Jane', **{ 'zip': '911-745', 'value': 1000.0, 'ref': '1044618427ff2782f0bbece0abd05f31' })) bank.add( Account( 'William John', **{ 'zip': '100-064', 'value': 6460.0, 'ref': '58ba2b9954cd278eda8a84147ca73c87', 'info': None })) if bank.transfer('William John', 'Smith Jane', 1000.0) is False: print('Failed') bank.fix_account('William John') bank.fix_account('Smith Jane') if bank.transfer('William John', 'Smith Jane', 1000.0) is False: print('Failed') else: print('Success')
from the_bank import Account, Bank if __name__ == "__main__": bank = Bank() bank.add( Account( "Smith Jane", zip="911-745", value=1000.0, ref="1044618427ff2782f0bbece0abd05f31", addr="paris", ) ) bank.add( Account( "William John", zip="100-064", value=6460.0, ref="58ba2b9954cd278eda8a84147ca73c87", info=None, other="This is the vice president of the corporation", addr="lyon", ) ) if bank.transfer("William John", "Smith Jane", 545.0) is False: print("Failed") else: print("Success")
#!/usr/bin/env python3 from the_bank import Account, Bank if __name__ == '__main__': pepe = Account('Pepe', zip=28032, value=0) papa = Account('Papa', addr="La mancha", value=0, b=3) pepe.value = 412 del papa.value bankia = Bank() bankia.add(pepe) bankia.add(papa) bankia.fix_account(papa) bankia.transfer('Pepe', 'Papa', 400) print("Papa value after transfer:", papa.value)
from the_bank import Account from the_bank import Bank thebank = Bank() acc1 = Account("test", value=100, zip=75000, addr='1 Boulevard Bessieres') acc2 = Account("test2", value=50, zip=3454, addr='rgreg') acc3 = Account("test3") thebank.add(acc1) thebank.add(acc2) thebank.add(acc3) thebank.transfer('test', 'test2', 50) thebank.transfer(1, 'test2', 50) thebank.transfer(1, 'test2', 50) thebank.fix_account('test3')
from the_bank import Account, Bank acc = Account() bk = Bank()
from the_bank import Account, Bank if __name__ == "__main__": Gege = { 'solde': 1500, 'previsionnel': 100, 'agence': 'Paris', 'value': 100000 } Holi = { 'solde': 800, 'previsionnel': 100, 'agence': 'Paris', 'value': 100000 } le_mechant = { 'solde': -5, 'previsionnel': 100, 'agence': 'aris', 'value': 100000 } g = Account("Gege", **Gege) h = Account("Holi", **Holi) lm = Account("le_mechant", **le_mechant) bank = Bank() bank.transfer(h, g, 500) bank.fix_account(0)