-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanking-kata-test.py
59 lines (39 loc) · 1.74 KB
/
banking-kata-test.py
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import unittest
from account import Account
class TestBankingKata(unittest.TestCase):
@classmethod
def setUp(self):
self.conta = Account()
def testAccountExists(self):
self.assertIsNotNone(self.conta)
def testAccountDepositAcceptsValue(self):
self.assertTrue(self.conta.deposit(100))
def testAccountDepositDontAcceptString(self):
with self.assertRaises(ValueError) as cm:
self.conta.deposit("100aa")
self.assertEqual(str(cm.exception), "Valor deve ser numerico")
def testAccountDepositDontAcceptNegative(self):
with self.assertRaises(ValueError) as cm:
self.assertFalse(self.conta.deposit(-9))
self.assertEqual(str(cm.exception), "Valor deve ser positivo")
def testAccountDepositShowsStatement(self):
self.conta.deposit(100)
self.assertEqual(self.conta.printStatement(), 100)
self.conta.deposit(200)
self.assertEqual(self.conta.printStatement(), 300)
def testAccountPrintStatementWorks(self):
self.assertEqual(self.conta.printStatement(), 0)
def testAccountWithdrawRaisesErrorWhenZeroBalance(self):
with self.assertRaises(ValueError) as cm:
self.conta.withdraw(1)
self.assertEqual(str(cm.exception), "Saldo Insuficiente")
def testAccountWithdrawShouldBeGreaterThanZero(self):
with self.assertRaises(ValueError) as cm:
self.conta.withdraw(0)
self.assertEqual(str(cm.exception), "Saque deve ser maior que zero")
def testAccountWithdrawShouldWithdraw(self):
self.conta.deposit(100)
self.conta.withdraw(100)
self.assertEqual(self.conta.printStatement(), 0)
if __name__ == '__main__':
unittest.main()