Turn your checks into tests that run every month
Write your profiling checks as small test functions, then run them on all three months at once.
2 parts · 3 and 10 min · part 2 on a computer
Free course. Your Maestro, an AI, .
Finding November's bad rows by eye worked once because you stopped to inspect the file before running the report. When the next monthly Glossary word arrives on a busy morning, a manual check is easy to skip. Putting your checks into a Glossary word of small test functions lets one command verify every monthly file the same way.
One expectation, one function
Open tests.py in the workbench below. The script loads each month's rows with csv.DictReader, loops through a list of functions called TESTS, and prints PASS or FAIL for each test on each month.
Every test function takes (rows, month) and returns True when every row meets the expectation, or False when any row breaks it. The starter file includes test_unique_order_ids(rows, month). It collects every r["order_id"] into a list ids and checks len(ids) == len(set(ids)). Because a set drops duplicates, the lengths match only when every order ID is unique: 2026-09 and 2026-10 return True, while 2026-11 (where S-1101 appears twice) returns False.
Keeping one rule per function tells you right away what broke. If you combined unique IDs, dates, and amounts into one big test function, a FAIL on 2026-11 would only say that November has a problem somewhere. With separate functions in TESTS, the loop prints each function's name (test.__name__) beside PASS or FAIL. Running every test across 2026-09, 2026-10, and 2026-11 also tests your new code against known good and bad files at once.
You will add two functions to tests.py and list them in TESTS:
test_dates_in_month(rows, month): Insales_2026-11.csv, orderS-1104hasorder_dateset to2026-10-31. Your function should returnFalsewhen any row's date falls outsidemonth. If you want to compareall()with aforloop here, ask your Maestro.test_amounts_are_non_negative_numbers(rows, month):csv.DictReaderreads every value as a string. In November,S-1102has"-80"andS-1105has"1,200". Your function should returnFalsefor a negative amount and for text that is not a number, without crashing on it. If your script crashes on"1,200"instead of printing FAIL, ask your Maestro wheretryandexceptbelong.
What passing tests still cannot catch
Running tests.py catches malformed files automatically, but passing every test never proves the data is accurate. These tests check structure and ranges: unique keys, dates inside the month, and numeric amounts zero or above.
Any error that stays inside those rules will pass. If an order for 540 was keyed into the export as 450, or if an entire order was left out before the export ran, every function in TESTS still prints PASS. Automated tests catch broken rows at the door; reconciling against an independent source like finance catches missing or miskeyed activity.
Try it
Run tests.py to see the first test run across all three months. Then write test_dates_in_month and test_amounts_are_non_negative_numbers, add them to TESTS, and run the script again. Your Maestro is right there if you want to talk through your logic.
A good place to stop. Up next: the workbench · 10 min · on a computer
Check your terminal output after running uv run tests.py. You should see nine lines: 2026-09 and 2026-10 print PASS for test_unique_order_ids, test_dates_in_month, and test_amounts_are_non_negative_numbers, while 2026-11 prints FAIL for all three.