From f33b4bb0603474911b85d39bfb4266167b0c8d42 Mon Sep 17 00:00:00 2001 From: Harlan Lieberman-Berg Date: Thu, 21 Dec 2023 18:48:48 -0500 Subject: [PATCH] feat(dcu): Add basic unit testing; fix default filename. --- .../importers/dcu/__init__.py | 2 +- .../Main_Checking_Account_Transactions.csv | 11 +++++++ ..._Checking_Account_Transactions.csv.extract | 31 +++++++++++++++++++ ...king_Account_Transactions.csv.file_account | 1 + ...hecking_Account_Transactions.csv.file_date | 1 + ...hecking_Account_Transactions.csv.file_name | 1 + .../importers/dcu/tests/dcu_csv_test.py | 18 +++++++++++ 7 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv create mode 100644 beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.extract create mode 100644 beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_account create mode 100644 beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_date create mode 100644 beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_name create mode 100644 beancount_reds_importers/importers/dcu/tests/dcu_csv_test.py diff --git a/beancount_reds_importers/importers/dcu/__init__.py b/beancount_reds_importers/importers/dcu/__init__.py index fc2281f..98055e9 100644 --- a/beancount_reds_importers/importers/dcu/__init__.py +++ b/beancount_reds_importers/importers/dcu/__init__.py @@ -10,7 +10,7 @@ class Importer(csvreader.Importer, banking.Importer): def custom_init(self): if not self.custom_init_run: self.max_rounding_error = 0.04 - self.filename_pattern_def = ".*Account Transactions" + self.filename_pattern_def = ".*Account_Transactions" self.header_identifier = "" self.column_labels_line = '"DATE","TRANSACTION TYPE","DESCRIPTION","AMOUNT","ID","MEMO","CURRENT BALANCE"' self.date_format = "%m/%d/%Y" diff --git a/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv new file mode 100644 index 0000000..b3dd46c --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv @@ -0,0 +1,11 @@ +"DATE","TRANSACTION TYPE","DESCRIPTION","AMOUNT","ID","MEMO","CURRENT BALANCE" +"12/31/2021","DEBIT","TRANSFER TO MBR ***0123 ACCT 4 MOBILE BANKING TRANSFER:123456789012345678 - SWEEP ACCOUNT","-$7,971.39","dwA4AEUAZQBKAGcAKwBGAG8ATwBQAEkAeQBiAHIAWAAvAGMAUwBVAFUAYgBzAG8AVwB2AEwAVwBNAGMARABQADQAVgBkAHcAVQA4AGkAQwA2AG8ARABTAGMAMQAxAEgAagBTAG8ANAB1ADAAcABuAFUAUwBsAHAAcQBZAFYAQgB4AFkAWABpADEARwBuAFcAcwBNADAAeQB5AGcAMgBBAFAARABFAFQARQBnAD0APQA","","$500.00" +"12/30/2021","CREDIT","ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 123456","$6,000.36","VwB0AG0AeABFADMANQB6AHYASQA1AGwAUQBZAEIAUgBvAFUAZQBEAEsASgA4ADAAdgB0ADYAWgBrAHgAbwBZAFkAWQBCAE4AdQArAGQAZABwAEYAZwA4AEkAdQB5AFQAbAByAHUARgBJAGoAcQBNADUAOABGADUAQgBlAHkAKwBpAHoAVQByAGsAYwBwAHgANQByADAATQBoAHIAUQBSADYASgAvAHkAegBRAD0APQA","","$8,471.39" +"12/29/2021","CREDIT","ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 123456","$256.00","VwBuAHAAUABxAHYAeQBSAFIANgB3ADgANQB6ADYAagB4ADcATwBtAHIAeQBjAEYAdQA1AGMAdwB3AE0AWQA0AHcANgBoAGUASABqAFYAVQBSAGEAdwBIAFYAeQBlAG8AWABKAHUAVwBNAGQARwAvAGgAUQBJAHUAbQBuAGIAYgBpAHIAZAB2AFQAVgA4AHMATQBVAHMAbQBGADQAbgAvAHQAWAA2ADIAVwBnAD0APQA","","$2,471.03" +"12/28/2021","DEBIT","TRANSFER TO MBR ***0123 ACCT 4 12/31/2021 03:24 348604. ROAD RUNNER PAYMENT - SWEEP ACCOUNT","-$50.50","LwBzADgAeABnAGsAbwBVAFAAYgBQADkAMgBRAGoAZgBHADkATwBXAHYAZgBYAFoAMwBKAGIASgBTAHoAdgB0AGsAUQA5AHEASwArAHoAZwBlAFUAdwBSAGcAbwA3AHQARwA3AFMATgBwAHQAagA3ADkAYQBzAFYAUABDAFUAMwBZAEYAOQBKAHIATAAyAEUAbABmAGwAcAB0AHcAZQBnAGsAawAxAEIANgBRAD0APQA","","$2,215.03" +"12/27/2021","CREDIT","ELECTRONIC DEPOSIT - ACME INCEXPENSIFY 000000","$25.00","VQAxAE8AdwA3ADcAdQB6AGgAawBOAFcAVwA3AG0AKwBRAFYAUgBPAGQATAByAC8ANABwAEYATQBMAHEAbwA3AFoAZgBFAFUARABaAFUAcABuAFcAcgBVAGgAUQA0ADkARgB4AFAAOAArAHIAZAArAHAATABTAEgAMQByADQATwByADYAZgA3AGEASwAyAGkAawBBAEYAeQBCAC8AeQAzAHQAZQBDAGgAYgB3AD0APQA","","$2,265.53" +"12/26/2021","CREDIT","ELECTRONIC DEPOSIT - RANDOMCORP RECEIVABLE","$141.67","aQBoAHgATgBGAHgAZABTAEcAUwB1AEIAVQBoAE4AYQBBAHUAbQBHAHoASgBsADUAQwBLAGsAaABHAHEAUgBRAGcATQBzAFcAMgBCAGIAKwBQAGMALwBaAGwAZABuAGkANABpAGoAUQBRAG4AWQB4AFYATgBqAFAAeQBaAE0AbQB6ADMALwB6AGoAMwBsAFUAeQBrAHYAMgB3AEwAbwAzADAAMwAwADAATAB3AD0APQA","","$2,240.53" +"12/25/2021","DEBIT","TRANSFER TO MBR ***0123 ACCT 4 12/22/2021 15:32 170124. - SWEEP ACCOUNT","-$2,500.99","dwBPAGUAcwBnAGUAVwBaAHgAUwArADgANQBQADcAWAAxADYAdgBCAGEAYgBqAFkAUwBZAG8AeQA5AGwAbwBoAGoAMQBYAEcAcwBPAFYAZgB1AEEAcAB1AEgATQB3AE8AOABhAEoATwBWAEoASQBqAFcAWAA0ADQAMQBsAGEATABZAFEAagBEAEgAMQBIAHcAdwB5AHQARABCAEsAWAAxAEcAMwB4AFEAVgBRAD0APQA","","$2,098.86" +"12/20/2021","DEBIT","TRANSFER TO MBR ***0123 ACCT 4 12/16/2021 21:32 51592. - SWEEP ACCOUNT","-$400.15","cwBBAFgAcQBTACsANgBlAGUAegBpADMARABjAEgAMwBTAGcAMgB6AHIATQAxAEsAQgAwADUAQwA3AHgAWAB4AFgAWAA1AEcAbgA4ADYARAByADQAQgBpAE8AKwBPAHAARABWAEkAMAA0AFMAaQBKADQAegBVADIATgA4ADkAdAB1AHoAdgA4AE4ARQBtAGUASgBGAG8AYgBiAHYAMgBqAE0AMwBYADUAbABRAD0APQA","","$4,599.85" +"12/18/2021","DEBIT","TRANSFER TO MBR ***0123 ACCT 3 12/16/2021 21:28 51547. - MONEY MARKET","-$5,000.00","cABXAGwATgBGADgAUgBmAG8AWgBaAC8AaQB1AC8AbgBMAEsARQB4AGcAcQBNAG8AYwBoADgAQgAwAFYAYwBJADIASwBQAGYAZwA2AHoAUgBJADIANABuAFcASwA0AEQAdQBpAHMANwBSAGkAVgBpAHAAVABkADgAUQAvACsAZwBMAHkAaQAyADMAVABwAGwAVQA2AEMAcwBMADAAZgB0AGgAYgBvAG4AZgBRAD0APQA","","$5,000.00" +"12/15/2021","CREDIT","ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 121521","$10,000.00","egBHAFMATQBCAGwAeABlAGoAdgBlAHMALwA1AEwAVgA3AFMAVgBJAEgANgBnADEAcwBYAG8AegBYAFQARQBrAEMAMQA2AHYAMABLADgAQwBzAFAARABEAGsANABIAGwAKwBWAEwAYwBuAEsALwBBAHgAUQBUAGwANABIAHYATABrAEQAegBtAEQARABHADgARwBvAFMAMQBDAGMAdQBwAFUATwA2ADQASABnAD0APQA","","$10,000.00" diff --git a/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.extract b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.extract new file mode 100644 index 0000000..bf5f972 --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.extract @@ -0,0 +1,31 @@ +2021-12-15 * "ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 121521" + Assets:Banks:DCU:Checking 10000.00 USD + +2021-12-18 * "TRANSFER TO MBR ***0123 ACCT 3 12/16/2021 21:28 51547. - MONEY MARKET" + Assets:Banks:DCU:Checking -5000.00 USD + +2021-12-20 * "TRANSFER TO MBR ***0123 ACCT 4 12/16/2021 21:32 51592. - SWEEP ACCOUNT" + Assets:Banks:DCU:Checking -400.15 USD + +2021-12-25 * "TRANSFER TO MBR ***0123 ACCT 4 12/22/2021 15:32 170124. - SWEEP ACCOUNT" + Assets:Banks:DCU:Checking -2500.99 USD + +2021-12-26 * "ELECTRONIC DEPOSIT - RANDOMCORP RECEIVABLE" + Assets:Banks:DCU:Checking 141.67 USD + +2021-12-27 * "ELECTRONIC DEPOSIT - ACME INCEXPENSIFY 000000" + Assets:Banks:DCU:Checking 25.00 USD + +2021-12-28 * "TRANSFER TO MBR ***0123 ACCT 4 12/31/2021 03:24 348604. ROAD RUNNER PAYMENT - SWEEP ACCOUNT" + Assets:Banks:DCU:Checking -50.50 USD + +2021-12-29 * "ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 123456" + Assets:Banks:DCU:Checking 256.00 USD + +2021-12-30 * "ELECTRONIC DEPOSIT - 3392 ACME INC DDEPOSIT 123456" + Assets:Banks:DCU:Checking 6000.36 USD + +2021-12-31 * "TRANSFER TO MBR ***0123 ACCT 4 MOBILE BANKING TRANSFER:123456789012345678 - SWEEP ACCOUNT" + Assets:Banks:DCU:Checking -7971.39 USD + +2022-01-01 balance Assets:Banks:DCU:Checking 500.00 USD diff --git a/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_account b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_account new file mode 100644 index 0000000..a44f4ba --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_account @@ -0,0 +1 @@ +Assets:Banks:DCU:Checking diff --git a/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_date b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_date new file mode 100644 index 0000000..021aea8 --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_date @@ -0,0 +1 @@ +2021-12-31 diff --git a/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_name b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_name new file mode 100644 index 0000000..25e8b53 --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/Main_Checking_Account_Transactions.csv.file_name @@ -0,0 +1 @@ +Main_Checking_Account_Transactions.csv diff --git a/beancount_reds_importers/importers/dcu/tests/dcu_csv_test.py b/beancount_reds_importers/importers/dcu/tests/dcu_csv_test.py new file mode 100644 index 0000000..dbadc22 --- /dev/null +++ b/beancount_reds_importers/importers/dcu/tests/dcu_csv_test.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + +from os import path +from beancount.ingest import regression_pytest as regtest +from beancount_reds_importers.importers import dcu + + +@regtest.with_importer( + dcu.Importer( + { + "main_account": "Assets:Banks:DCU:Checking", + "currency": "USD", + } + ) +) +@regtest.with_testdir(path.dirname(__file__)) +class TestDCUCSV(regtest.ImporterTestBase): + pass