forked from sturivny/atm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests_atm.py
99 lines (68 loc) · 2.46 KB
/
tests_atm.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import unittest
from atm import Atm
from atm_exceptions import *
def setUpModule():
print "Setup before all"
def tearDownModule():
print "Tear Down after all"
class TestAtm(unittest.TestCase):
def setUp(self):
self.atm = Atm()
self.atm.enter_pin(777)
def test_enter_true_pin_and_check_balance(self):
'''Enter the correct pin and check the balance'''
balance = self.atm.check_balance()
self.assertEqual(10000, balance)
def test_gives_4000_money(self):
'''Give money in the amount of 4000'''
money = self.atm.get_money(4000)
self.assertEqual(4000, money)
def test_gives_10000_money(self):
'''Give money in the amount of 10000'''
money = self.atm.get_money(10000)
self.assertEqual(10000, money)
def test_gives_9999_money(self):
'''Give money in the amount of 9999'''
money = self.atm.get_money(9999)
self.assertEqual(9999, money)
def test_gives_0_money(self):
'''Give money in the amount of 0'''
money = self.atm.get_money(0)
self.assertEqual(0, money)
@unittest.skip("Bug #0001")
def test_gives_min_1_money(self):
'''A negative amount is given'''
money = self.atm.get_money(-1)
self.assertEqual(0, money)
def test_rise_1000000_money(self):
'''Add the amount of 1000000'''
rise_money = self.atm._rise_money(1000000)
self.assertEqual(1010000, rise_money)
def test_rise_0_money(self):
'''Add the amount of 0'''
rise_money = self.atm._rise_money(0)
self.assertEqual(10000, rise_money)
@unittest.skip("Bug #0002")
def test_rise_min_1_money(self):
'''A negative amount is added'''
rise_money = self.atm._rise_money(-1)
self.assertEqual(10000, rise_money)
class TestAtmExceptions(unittest.TestCase):
def setUp(self):
self.atm = Atm()
self.atm.enter_pin(777)
self.atm2 = Atm()
def test_gives_10001_money(self):
'''Trying to give the amount more available'''
try:
self.atm.get_money(10001)
except Exception as e:
self.assertEqual('Atm balance is no enough!!!', e.message)
def test_incorrect_pin(self):
'''Testing an incorrect pin'''
try:
self.atm2.enter_pin(77)
except Exception as e:
self.assertEqual('Incorrect Pin!!!', e.message)
if __name__ == '__main__':
unittest.main()