forked from blksail-edu/python-refresher
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_bank.py
More file actions
32 lines (25 loc) · 1.02 KB
/
test_bank.py
File metadata and controls
32 lines (25 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import unittest
import bank
class TestBank(unittest.TestCase):
def test_init(self):
test_account = bank.Bank("Joe", 1, 100)
self.assertEqual(test_account.name, "Joe")
self.assertEqual(test_account.balance, 100)
self.assertEqual(test_account.account_number, 1)
def test_withdraw(self):
test_account = bank.Bank("Joe", 1, 100)
self.assertEqual(test_account.withdraw(50), 50)
self.assertEqual(test_account.withdraw(20), 30)
with self.assertRaises(ValueError):
test_account.withdraw(100)
def test_deposit(self):
test_account = bank.Bank("Joe", 20, 100)
self.assertEqual(test_account.deposit(50), 150)
self.assertEqual(test_account.deposit(40), 190)
def test_balance(self):
test_account = bank.Bank("Joe", 1, 100)
self.assertEqual(test_account.print_balance(), 100)
test_account.deposit(50)
self.assertEqual(test_account.print_balance(), 150)
if __name__ == "__main__":
unittest.main()