Esempio n. 1
0
 def test_transactions_with_transfer(self):
     mary_transactions = [
         ('OPEN', 100, 100),
         ('WITHDRAWAL', -20, 80),
     ]
     dana_transactions = [
         ('OPEN', 0, 0),
         ('DEPOSIT', 20, 20),
     ]
     mary_account = BankAccount(balance=100)
     dana_account = BankAccount(balance=0)
     mary_account.transfer(dana_account, 20)
     self.assertEqual(mary_account.transactions, mary_transactions)
     self.assertEqual(dana_account.transactions, dana_transactions)
Esempio n. 2
0
 def test_balance_cannot_be_written(self):
     account1 = BankAccount()
     account2 = BankAccount(100)
     self.assertEqual(account1.balance, 0)
     with self.assertRaises(Exception):
         account1.balance = 50
     self.assertEqual(account1.balance, 0)
     self.assertEqual(account2.balance, 100)
     with self.assertRaises(Exception):
         account2.balance = 50
     self.assertEqual(account2.balance, 100)
     account1.deposit(100)
     account2.deposit(10)
     self.assertEqual(account1.balance, 100)
     self.assertEqual(account2.balance, 110)
     with self.assertRaises(Exception):
         account2.balance = 500
     self.assertEqual(account2.balance, 110)
     account2.transfer(account1, 50)
     self.assertEqual(account1.balance, 150)
     self.assertEqual(account2.balance, 60)
Esempio n. 3
0
 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)