Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
and some very minor changes in source
- Loading branch information
Showing
12 changed files
with
274 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import os | ||
|
||
import pytest | ||
|
||
from .source_test import check_source_example | ||
from beancount.ingest.importers.csv import Importer as CSVImporter, Col | ||
|
||
testdata_dir = os.path.realpath( | ||
os.path.join( | ||
os.path.dirname(__file__), '..', '..', 'testdata', 'source', 'generic_importer')) | ||
|
||
examples = [ | ||
'test_basic', | ||
'test_training_examples' | ||
] | ||
|
||
importer = CSVImporter({Col.DATE: 'Date', | ||
Col.NARRATION1: 'Description', | ||
Col.AMOUNT: 'Amount', | ||
}, | ||
'Assets:Bank', | ||
'USD', | ||
'"Date","Description","Amount"', | ||
) | ||
|
||
|
||
@pytest.mark.parametrize('name', examples) | ||
def test_source(name: str): | ||
check_source_example( | ||
example_dir=os.path.join(testdata_dir, name), | ||
source_spec={ | ||
'module': 'beancount_import.source.generic_importer_source', | ||
'directory': testdata_dir, | ||
'account': 'Assets:Bank', | ||
'importer': importer, | ||
}, | ||
replacements=[(testdata_dir, '<testdata>')]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
"Date","Description","Amount" | ||
2020-01-01,by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-,-1 | ||
2020-01-01,by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-,-1 | ||
2020-01-02,BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-,1 | ||
2020-01-02,ATM-WD Some Random ATM Machine,500 | ||
2020-01-02,BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-,1 | ||
2020-01-05,Transfer to 1234567890123,300 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Assets:Bank |
107 changes: 107 additions & 0 deletions
107
testdata/source/generic_importer/test_basic/import_results.beancount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
;; date: 2020-01-01 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "-1 USD", | ||
; "date": "2020-01-01", | ||
; "key_value_pairs": { | ||
; "desc": "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-01 * "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Assets:Bank -1 USD | ||
source_desc: "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Expenses:FIXME 1 USD | ||
|
||
;; date: 2020-01-01 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "-1 USD", | ||
; "date": "2020-01-01", | ||
; "key_value_pairs": { | ||
; "desc": "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-01 * "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Assets:Bank -1 USD | ||
source_desc: "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Expenses:FIXME 1 USD | ||
|
||
;; date: 2020-01-02 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "1 USD", | ||
; "date": "2020-01-02", | ||
; "key_value_pairs": { | ||
; "desc": "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-02 * "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Assets:Bank 1 USD | ||
source_desc: "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Expenses:FIXME -1 USD | ||
|
||
;; date: 2020-01-02 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "1 USD", | ||
; "date": "2020-01-02", | ||
; "key_value_pairs": { | ||
; "desc": "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-02 * "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Assets:Bank 1 USD | ||
source_desc: "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Expenses:FIXME -1 USD | ||
|
||
;; date: 2020-01-02 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "500 USD", | ||
; "date": "2020-01-02", | ||
; "key_value_pairs": { | ||
; "desc": "ATM-WD Some Random ATM Machine" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-02 * "ATM-WD Some Random ATM Machine" | ||
Assets:Bank 500 USD | ||
source_desc: "ATM-WD Some Random ATM Machine" | ||
Expenses:FIXME -500 USD | ||
|
||
;; date: 2020-01-05 | ||
;; info: null | ||
|
||
; features: [ | ||
; { | ||
; "amount": "300 USD", | ||
; "date": "2020-01-05", | ||
; "key_value_pairs": { | ||
; "desc": "Transfer to 1234567890123" | ||
; }, | ||
; "source_account": "Assets:Bank" | ||
; } | ||
; ] | ||
2020-01-05 * "Transfer to 1234567890123" | ||
Assets:Bank 300 USD | ||
source_desc: "Transfer to 1234567890123" | ||
Expenses:FIXME -300 USD |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1900-01-01 open Assets:Bank |
1 change: 1 addition & 0 deletions
1
testdata/source/generic_importer/test_basic/training_examples.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
1 change: 1 addition & 0 deletions
1
testdata/source/generic_importer/test_training_examples/accounts.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Assets:Bank |
1 change: 1 addition & 0 deletions
1
testdata/source/generic_importer/test_training_examples/import_results.beancount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
41 changes: 41 additions & 0 deletions
41
testdata/source/generic_importer/test_training_examples/journal.beancount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
1900-01-01 open Assets:Bank | ||
1900-01-01 open Assets:Cash | ||
1900-01-01 open Expenses:Misc | ||
1900-01-01 open Liabilities:JohnDoe | ||
|
||
|
||
2020-01-01 * "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Assets:Bank -1 USD | ||
source_desc: "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
cleared: TRUE | ||
Expenses:Misc 1 USD | ||
|
||
2020-01-01 * "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
Assets:Bank -1 USD | ||
source_desc: "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
cleared: TRUE | ||
Expenses:Misc 1 USD | ||
|
||
2020-01-02 * "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Assets:Bank 1 USD | ||
source_desc: "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
cleared: TRUE | ||
Expenses:Misc -1 USD | ||
|
||
2020-01-02 * "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
Assets:Bank 1 USD | ||
source_desc: "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
cleared: TRUE | ||
Expenses:Misc -1 USD | ||
|
||
2020-01-02 * "ATM-WD Some Random ATM Machine" | ||
Assets:Bank 500 USD | ||
source_desc: "ATM-WD Some Random ATM Machine" | ||
cleared: TRUE | ||
Assets:Cash -500 USD | ||
|
||
2020-01-05 * "Transfer to 1234567890123" | ||
Assets:Bank 300 USD | ||
source_desc: "Transfer to 1234567890123" | ||
cleared: TRUE | ||
Liabilities:JohnDoe -300 USD |
68 changes: 68 additions & 0 deletions
68
testdata/source/generic_importer/test_training_examples/training_examples.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
[ | ||
[ | ||
{ | ||
"amount": "-1 USD", | ||
"date": "2020-01-01", | ||
"key_value_pairs": { | ||
"desc": "by debit card-OTHPG 063441 GOOGLE CLOUD INDIA PVTTHANE-" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Expenses:Misc" | ||
], | ||
[ | ||
{ | ||
"amount": "-1 USD", | ||
"date": "2020-01-01", | ||
"key_value_pairs": { | ||
"desc": "by debit card-OTHPG 063444 GOOGLE CLOUD INDIA PVTTHANE-" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Expenses:Misc" | ||
], | ||
[ | ||
{ | ||
"amount": "1 USD", | ||
"date": "2020-01-02", | ||
"key_value_pairs": { | ||
"desc": "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Expenses:Misc" | ||
], | ||
[ | ||
{ | ||
"amount": "1 USD", | ||
"date": "2020-01-02", | ||
"key_value_pairs": { | ||
"desc": "BULK POSTING- 00000008237 250120 GOOGLE CLOUD INDIA PVT-" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Expenses:Misc" | ||
], | ||
[ | ||
{ | ||
"amount": "500 USD", | ||
"date": "2020-01-02", | ||
"key_value_pairs": { | ||
"desc": "ATM-WD Some Random ATM Machine" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Assets:Cash" | ||
], | ||
[ | ||
{ | ||
"amount": "300 USD", | ||
"date": "2020-01-05", | ||
"key_value_pairs": { | ||
"desc": "Transfer to 1234567890123" | ||
}, | ||
"source_account": "Assets:Bank" | ||
}, | ||
"Liabilities:JohnDoe" | ||
] | ||
] |