-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from tarioch/bugfix/missing_fx
Bugfix/missing fx
- Loading branch information
Showing
15 changed files
with
117 additions
and
56 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
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
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
Empty file.
Empty file.
Empty file.
3 changes: 3 additions & 0 deletions
3
...iochbctools/plugins/data/generate_base_ccy_prices/entry_already_exists_expected.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,3 @@ | ||
2020-01-01 price USD 1.2 CHF | ||
2020-01-02 price FOO 1 USD | ||
2020-01-02 price FOO 1.7 CHF |
4 changes: 4 additions & 0 deletions
4
...tariochbctools/plugins/data/generate_base_ccy_prices/entry_already_exists_input.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,4 @@ | ||
plugin "tariochbctools.plugins.generate_base_ccy_prices" "CHF" | ||
2020-01-01 price USD 1.2 CHF | ||
2020-01-02 price FOO 1 USD | ||
2020-01-02 price FOO 1.7 CHF |
1 change: 1 addition & 0 deletions
1
tests/tariochbctools/plugins/data/generate_base_ccy_prices/missing_fx_expected.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 @@ | ||
2020-01-02 price FOO 1 USD |
2 changes: 2 additions & 0 deletions
2
tests/tariochbctools/plugins/data/generate_base_ccy_prices/missing_fx_input.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,2 @@ | ||
plugin "tariochbctools.plugins.generate_base_ccy_prices" "CHF" | ||
2020-01-02 price FOO 1 USD |
3 changes: 3 additions & 0 deletions
3
tests/tariochbctools/plugins/data/generate_base_ccy_prices/normal_expected.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,3 @@ | ||
2020-01-01 price USD 1.2 CHF | ||
2020-01-02 price FOO 1 USD | ||
2020-01-02 price FOO 1.2 CHF |
3 changes: 3 additions & 0 deletions
3
tests/tariochbctools/plugins/data/generate_base_ccy_prices/normal_input.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,3 @@ | ||
plugin "tariochbctools.plugins.generate_base_ccy_prices" "CHF" | ||
2020-01-01 price USD 1.2 CHF | ||
2020-01-02 price FOO 1 USD |
35 changes: 35 additions & 0 deletions
35
tests/tariochbctools/plugins/test_generate_base_ccy_prices.py
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,35 @@ | ||
import os | ||
from io import StringIO | ||
from beancount.parser import printer | ||
from beancount import loader | ||
import pytest | ||
|
||
|
||
@pytest.mark.parametrize("testCase", [ | ||
"normal", | ||
"missing_fx", | ||
"entry_already_exists" | ||
]) | ||
def test_data(testCase): | ||
dataDir = os.path.join( | ||
os.path.dirname(__file__), "data", "generate_base_ccy_prices" | ||
) | ||
inputPath = os.path.join(dataDir, testCase + "_input.beancount") | ||
expectedPath = os.path.join(dataDir, testCase + "_expected.beancount") | ||
|
||
entries, errors, _ = loader.load_file(inputPath) | ||
if errors: | ||
printer.print_errors(errors) | ||
assert False | ||
|
||
actualStrIo = StringIO() | ||
printer.print_entries(entries, file=actualStrIo) | ||
actual = actualStrIo.getvalue() | ||
|
||
if os.path.isfile(expectedPath): | ||
with open(expectedPath, 'r') as expectedFile: | ||
expected = expectedFile.read() | ||
assert actual == expected | ||
else: | ||
with open(expectedPath, 'w') as expectedFile: | ||
expectedFile.write(actual) |