-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_balance.py
executable file
·67 lines (52 loc) · 2.08 KB
/
test_balance.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
#!/Library/FrameWorks/Python.framework/Versions/3.5/bin/python3
from balance import TransactionManager
from balance import Transaction
import os
import unittest
class TestTransaction(unittest.TestCase):
def test_constructor_positive_simple(self):
t = Transaction(100, [])
self.assertEqual(t.is_negative, False)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 0)
def test_constructor_negative_simple(self):
t = Transaction(-100, [])
self.assertEqual(t.is_negative, True)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 0)
def test_constructor_positive_small(self):
t = Transaction(100.01, [])
self.assertEqual(t.is_negative, False)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 1)
def test_constructor_positive_big(self):
t = Transaction(100.99, [])
self.assertEqual(t.is_negative, False)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 99)
def test_constructor_negative_small(self):
t = Transaction(-100.99, [])
self.assertEqual(t.is_negative, True)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 99)
def test_constructor_negative_big(self):
t = Transaction(-100.01, [])
self.assertEqual(t.is_negative, True)
self.assertEqual(t.dollars, 100)
self.assertEqual(t.cents, 1)
def test_string_positive_simple(self):
t = Transaction(100.01, [])
t.date = t.date.replace(1995, 12, 12)
self.assertEqual(str(t), "100.01 on 1995-12-12")
def test_string_negative_simple(self):
t = Transaction(-100.01, [])
t.date = t.date.replace(1995, 12, 12)
self.assertEqual(str(t), "-100.01 on 1995-12-12")
def test_string_complex(self):
t = Transaction(100, ["birthday", "toy"])
t.date = t.date.replace(1995, 12, 12)
self.assertEqual(str(t), "100.00 on 1995-12-12 #birthday #toy")
class TestTransactionManager(unittest.TestCase):
pass
if __name__ == "__main__":
unittest.main()