forked from travishathaway/python-ach
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_data_types.py
More file actions
61 lines (53 loc) · 2.34 KB
/
test_data_types.py
File metadata and controls
61 lines (53 loc) · 2.34 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
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
import nose.tools as nt
from ach import data_types as dt
class TestDataTypes(object):
def setup(self):
'''
We need to set up some data types
'''
self.header = dt.Header(
'123456789', '123456789', 'A', 'YOUR BANK', 'YOUR COMPANY'
)
self.file_control = dt.FileControl(1, 1, 0, 213123123, 12300, 12300)
self.batch_header = dt.BatchHeader()
self.batch_control = dt.BatchControl()
self.entry_detail = dt.EntryDetail()
self.addenda_record = dt.AddendaRecord()
def test_line_width(self):
'''
Test each record to make sure they are 94 characters wide
'''
nt.assert_equals(len(self.header.get_row()), 94)
nt.assert_equals(len(self.file_control.get_row()), 94)
nt.assert_equals(len(self.batch_header.get_row()), 94)
nt.assert_equals(len(self.batch_control.get_row()), 94)
nt.assert_equals(len(self.entry_detail.get_row()), 94)
nt.assert_equals(len(self.addenda_record.get_row()), 94)
def test_invalid_property_header(self):
'''
We make sure that properties that are not define in "numeric_fields"
or "alpha_numeric_fields" cannot be defined as object properties.
'''
nt.assert_raises(dt.AchError, setattr, self.header,
'test_property', 'testtesttest')
nt.assert_raises(dt.AchError, setattr, self.file_control,
'test_property', 'testtesttest')
nt.assert_raises(dt.AchError, setattr, self.batch_header,
'test_property', 'testtesttest')
nt.assert_raises(dt.AchError, setattr, self.batch_control,
'test_property', 'testtesttest')
nt.assert_raises(dt.AchError, setattr, self.entry_detail,
'test_property', 'testtesttest')
nt.assert_raises(dt.AchError, setattr, self.addenda_record,
'test_property', 'testtesttest')
def test_check_digit(self):
'''
Ensure our check digit is being calculate appropriately on
entry detail records
'''
self.entry_detail.recv_dfi_id = '11100002'
self.entry_detail.calc_check_digit()
nt.assert_equal(
self.entry_detail.recv_dfi_id + self.entry_detail.check_digit,
'111000025'
)