A row count is the number of records represented in a file, batch, or database result. In payment processing, checking this simple metric confirms that an ACH file was read and that its expected record types are present before deeper troubleshooting begins. section 2.4.1 section 2.5.2
Use row counts at several points in the processing workflow:
- Count the lines in the source file with Unix wc -l, PowerShell Get-Content and Measure-Object, or a file editor. section 2.4.1
- Assert individual record-type counts and the total count when loading an unparsed ACH batch. section 11.5.1
- Query parsed tables and compare their totals with expected results, while also checking that no exceptions were written. section 11.5.1
- Repeat the checks after adding new processing, such as IAT batches, to detect regressions in existing PPD processing. section 11.5.1
Counting an ACH batch
A unit test loads a mixed PPD file, queries counts from record-type tables, adds those counts into a total, and compares the result with the expected batch count. A separate query applies the same pattern to parsed PPD or IAT tables. section 11.5.1
Listing 11.10 Testing PPD batches
def test_good_unparsed_records_only(self, parser):
filename = "ppd-mixed.ach" #1
dir_path = os.path.dirname(os.path.realpath(__file__)) #2
file_path = os.path.join(dir_path, "data", filename) #2
expected_exceptions_result: int = 0 #3
expected_total_records_result: int = 14 #3
ach_file_id = SqlUtils. #4
➥create_ach_file_record(filename, "123456789") #4
#4
parser.parse(ach_file_id, file_path) #4
exceptions = SqlUtils.get_exceptions() #4
#4
with SqlUtils.get_db() as conn: #5
record_count_type1 = conn.execute( #5
"SELECT COUNT(*) FROM ach_records_type_1" #5
).fetchone()[0] #5
… #5
record_count_type9 = conn.execute( #5
"SELECT COUNT(*) FROM ach_records_type_9" #5
).fetchone()[0] #5
#5
total_record_count = ( #6
record_count_type1 #6
+ record_count_type5 #6
+ record_count_type6 #6
+ record_count_type7 #6
+ record_count_type8 #6
+ record_count_type9 #6
) #6
#6
assert record_count_type1 == 1, #7
f"Expected 1, but got {record_count_type1}" #7
… #7
assert ( #7
total_record_count == expected_total_records_result #7
), f"Expected {expected_total_records_result}, but got #7
{total_record_count}" #7
… #7
Inspect the PPD-batch test listing to see how a parser is invoked, exceptions are retrieved, and record-type counts are assembled into a total. section 11.5.1
