-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjournalentry.py
43 lines (37 loc) · 1.2 KB
/
journalentry.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
from dataclasses import dataclass
import datetime
import unittest
from amount import Amount
@dataclass
class JournalEntry:
date: datetime.date
amount: Amount
debit_account: str
credit_account: str
description: str
source: str
source_location: str
def __post_init__(self):
assert isinstance(self.date, datetime.date)
assert isinstance(self.amount, Amount)
assert isinstance(self.debit_account, str)
assert isinstance(self.credit_account, str)
assert isinstance(self.description, str)
assert isinstance(self.source, str)
assert isinstance(self.source_location, str)
class Test(unittest.TestCase):
def test_make_ok(self):
tests = (None, 'my description')
for test in tests:
x = JournalEntry(
date=datetime.date(1,1,1),
amount=Amount(dollars=100, cents=23),
debit_account='Cash',
credit_account='Loan',
description="what happened",
source="source.txt",
source_location="line 0"
)
self.assertTrue(isinstance(x, JournalEntry))
if __name__ == '__main__':
unittest.main()