diff options
Diffstat (limited to 'beancount_extras_kris7t')
5 files changed, 61 insertions, 60 deletions
diff --git a/beancount_extras_kris7t/plugins/closing_balance_test.py b/beancount_extras_kris7t/plugins/closing_balance_test.py index 40115bf..eab377c 100644 --- a/beancount_extras_kris7t/plugins/closing_balance_test.py +++ b/beancount_extras_kris7t/plugins/closing_balance_test.py | |||
@@ -3,13 +3,13 @@ __license__ = 'GNU GPLv2' | |||
3 | 3 | ||
4 | import unittest | 4 | import unittest |
5 | 5 | ||
6 | from beancount import loader | 6 | from beancount.loader import load_doc |
7 | from beancount.parser import cmptest | 7 | from beancount.parser import cmptest |
8 | 8 | ||
9 | 9 | ||
10 | class TestClosingBalance(cmptest.TestCase): | 10 | class TestClosingBalance(cmptest.TestCase): |
11 | 11 | ||
12 | @loader.load_doc() | 12 | @load_doc() |
13 | def test_close_account_correct(self, entries, errors, options_map): | 13 | def test_close_account_correct(self, entries, errors, options_map): |
14 | ''' | 14 | ''' |
15 | plugin "beancount_extras_kris7t.plugins.closing_balance" | 15 | plugin "beancount_extras_kris7t.plugins.closing_balance" |
@@ -47,7 +47,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
47 | 2020-03-15 close Assets:Checking | 47 | 2020-03-15 close Assets:Checking |
48 | ''', entries) | 48 | ''', entries) |
49 | 49 | ||
50 | @loader.load_doc(expect_errors=True) | 50 | @load_doc(expect_errors=True) |
51 | def test_close_account_incorrect(self, entries, errors, options_map): | 51 | def test_close_account_incorrect(self, entries, errors, options_map): |
52 | ''' | 52 | ''' |
53 | plugin "beancount_extras_kris7t.plugins.closing_balance" | 53 | plugin "beancount_extras_kris7t.plugins.closing_balance" |
@@ -86,7 +86,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
86 | ''', entries) | 86 | ''', entries) |
87 | self.assertRegex(errors[0].message, '^Balance failed for \'Assets:Checking\'') | 87 | self.assertRegex(errors[0].message, '^Balance failed for \'Assets:Checking\'') |
88 | 88 | ||
89 | @loader.load_doc() | 89 | @load_doc() |
90 | def test_close_account_zero(self, entries, errors, options_map): | 90 | def test_close_account_zero(self, entries, errors, options_map): |
91 | ''' | 91 | ''' |
92 | plugin "beancount_extras_kris7t.plugins.closing_balance" | 92 | plugin "beancount_extras_kris7t.plugins.closing_balance" |
@@ -107,7 +107,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
107 | 2020-03-15 close Assets:Checking | 107 | 2020-03-15 close Assets:Checking |
108 | ''', entries) | 108 | ''', entries) |
109 | 109 | ||
110 | @loader.load_doc(expect_errors=True) | 110 | @load_doc(expect_errors=True) |
111 | def test_invalid_close_to(self, entries, errors, options_map): | 111 | def test_invalid_close_to(self, entries, errors, options_map): |
112 | ''' | 112 | ''' |
113 | plugin "beancount_extras_kris7t.plugins.closing_balance" | 113 | plugin "beancount_extras_kris7t.plugins.closing_balance" |
diff --git a/beancount_extras_kris7t/plugins/default_tolerance_test.py b/beancount_extras_kris7t/plugins/default_tolerance_test.py index 2e5c629..4ef84c1 100644 --- a/beancount_extras_kris7t/plugins/default_tolerance_test.py +++ b/beancount_extras_kris7t/plugins/default_tolerance_test.py | |||
@@ -3,13 +3,13 @@ __license__ = 'GNU GPLv2' | |||
3 | 3 | ||
4 | import unittest | 4 | import unittest |
5 | 5 | ||
6 | from beancount import loader | 6 | from beancount.loader import load_doc |
7 | from beancount.parser import cmptest | 7 | from beancount.parser import cmptest |
8 | 8 | ||
9 | 9 | ||
10 | class DefaultToleranceTest(cmptest.TestCase): | 10 | class DefaultToleranceTest(cmptest.TestCase): |
11 | 11 | ||
12 | @loader.load_doc() | 12 | @load_doc() |
13 | def test_account_with_tolerance(self, entries, errors, options_map): | 13 | def test_account_with_tolerance(self, entries, errors, options_map): |
14 | ''' | 14 | ''' |
15 | plugin "beancount_extras_kris7t.plugins.default_tolerance" | 15 | plugin "beancount_extras_kris7t.plugins.default_tolerance" |
@@ -28,7 +28,7 @@ class DefaultToleranceTest(cmptest.TestCase): | |||
28 | 2020-01-01 balance Assets:Checking 0 ~ 10 USD | 28 | 2020-01-01 balance Assets:Checking 0 ~ 10 USD |
29 | ''', entries) | 29 | ''', entries) |
30 | 30 | ||
31 | @loader.load_doc() | 31 | @load_doc() |
32 | def test_account_with_tolerance_override(self, entries, errors, options_map): | 32 | def test_account_with_tolerance_override(self, entries, errors, options_map): |
33 | ''' | 33 | ''' |
34 | plugin "beancount_extras_kris7t.plugins.default_tolerance" | 34 | plugin "beancount_extras_kris7t.plugins.default_tolerance" |
@@ -47,7 +47,7 @@ class DefaultToleranceTest(cmptest.TestCase): | |||
47 | 2020-01-01 balance Assets:Checking 10 ~ 20 USD | 47 | 2020-01-01 balance Assets:Checking 10 ~ 20 USD |
48 | ''', entries) | 48 | ''', entries) |
49 | 49 | ||
50 | @loader.load_doc() | 50 | @load_doc() |
51 | def test_account_with_tolerance_override_zero(self, entries, errors, options_map): | 51 | def test_account_with_tolerance_override_zero(self, entries, errors, options_map): |
52 | ''' | 52 | ''' |
53 | plugin "beancount_extras_kris7t.plugins.default_tolerance" | 53 | plugin "beancount_extras_kris7t.plugins.default_tolerance" |
@@ -66,7 +66,7 @@ class DefaultToleranceTest(cmptest.TestCase): | |||
66 | 2020-01-01 balance Assets:Checking 0 ~ 0 USD | 66 | 2020-01-01 balance Assets:Checking 0 ~ 0 USD |
67 | ''', entries) | 67 | ''', entries) |
68 | 68 | ||
69 | @loader.load_doc() | 69 | @load_doc() |
70 | def test_account_without_tolerance(self, entries, errors, options_map): | 70 | def test_account_without_tolerance(self, entries, errors, options_map): |
71 | ''' | 71 | ''' |
72 | plugin "beancount_extras_kris7t.plugins.default_tolerance" | 72 | plugin "beancount_extras_kris7t.plugins.default_tolerance" |
@@ -87,7 +87,7 @@ class DefaultToleranceTest(cmptest.TestCase): | |||
87 | 2020-01-02 balance Assets:Checking 10 ~ 20 USD | 87 | 2020-01-02 balance Assets:Checking 10 ~ 20 USD |
88 | ''', entries) | 88 | ''', entries) |
89 | 89 | ||
90 | @loader.load_doc(expect_errors=True) | 90 | @load_doc(expect_errors=True) |
91 | def test_account_with_invalid_tolerance(self, entries, errors, options_map): | 91 | def test_account_with_invalid_tolerance(self, entries, errors, options_map): |
92 | ''' | 92 | ''' |
93 | plugin "beancount_extras_kris7t.plugins.default_tolerance" | 93 | plugin "beancount_extras_kris7t.plugins.default_tolerance" |
diff --git a/beancount_extras_kris7t/plugins/selective_implicit_prices_test.py b/beancount_extras_kris7t/plugins/selective_implicit_prices_test.py index 6ead45d..b4a9d8e 100644 --- a/beancount_extras_kris7t/plugins/selective_implicit_prices_test.py +++ b/beancount_extras_kris7t/plugins/selective_implicit_prices_test.py | |||
@@ -6,15 +6,15 @@ import unittest | |||
6 | 6 | ||
7 | from beancount.core.number import D | 7 | from beancount.core.number import D |
8 | from beancount.core import data | 8 | from beancount.core import data |
9 | from beancount.loader import load_doc | ||
9 | from beancount.parser import cmptest | 10 | from beancount.parser import cmptest |
10 | from beancount import loader | ||
11 | 11 | ||
12 | from beancount_extras_kris7t.plugins import selective_implicit_prices as implicit_prices | 12 | from beancount_extras_kris7t.plugins import selective_implicit_prices as implicit_prices |
13 | 13 | ||
14 | 14 | ||
15 | class TestImplicitPrices(cmptest.TestCase): | 15 | class TestImplicitPrices(cmptest.TestCase): |
16 | 16 | ||
17 | @loader.load_doc() | 17 | @load_doc() |
18 | def test_add_implicit_prices__all_cases(self, entries, _, options_map): | 18 | def test_add_implicit_prices__all_cases(self, entries, _, options_map): |
19 | """ | 19 | """ |
20 | 1702-04-02 commodity USD | 20 | 1702-04-02 commodity USD |
@@ -124,7 +124,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
124 | actual = (price.currency, price.amount.currency, price.amount.number) | 124 | actual = (price.currency, price.amount.currency, price.amount.number) |
125 | self.assertEqual(expected, actual) | 125 | self.assertEqual(expected, actual) |
126 | 126 | ||
127 | @loader.load_doc() | 127 | @load_doc() |
128 | def test_add_implicit_prices__other_account(self, entries, errors, options_map): | 128 | def test_add_implicit_prices__other_account(self, entries, errors, options_map): |
129 | """ | 129 | """ |
130 | 2013-01-01 commodity HOOL | 130 | 2013-01-01 commodity HOOL |
@@ -185,7 +185,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
185 | 185 | ||
186 | """, new_entries) | 186 | """, new_entries) |
187 | 187 | ||
188 | @loader.load_doc() | 188 | @load_doc() |
189 | def test_add_implicit_prices__duplicates_on_same_transaction(self, | 189 | def test_add_implicit_prices__duplicates_on_same_transaction(self, |
190 | entries, _, options_map): | 190 | entries, _, options_map): |
191 | """ | 191 | """ |
@@ -234,7 +234,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
234 | 234 | ||
235 | """, new_entries) | 235 | """, new_entries) |
236 | 236 | ||
237 | @loader.load_doc() | 237 | @load_doc() |
238 | def test_add_implicit_prices__duplicates_on_different_transactions(self, | 238 | def test_add_implicit_prices__duplicates_on_different_transactions(self, |
239 | entries, _, | 239 | entries, _, |
240 | options_map): | 240 | options_map): |
@@ -296,7 +296,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
296 | 296 | ||
297 | """, new_entries) | 297 | """, new_entries) |
298 | 298 | ||
299 | @loader.load_doc() | 299 | @load_doc() |
300 | def test_add_implicit_prices__duplicates_overloaded(self, entries, _, options_map): | 300 | def test_add_implicit_prices__duplicates_overloaded(self, entries, _, options_map): |
301 | """ | 301 | """ |
302 | 2013-01-01 commodity HOOL | 302 | 2013-01-01 commodity HOOL |
@@ -343,7 +343,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
343 | 343 | ||
344 | """, new_entries) | 344 | """, new_entries) |
345 | 345 | ||
346 | @loader.load_doc() | 346 | @load_doc() |
347 | def test_add_implicit_prices__not_enabled(self, entries, errors, options_map): | 347 | def test_add_implicit_prices__not_enabled(self, entries, errors, options_map): |
348 | """ | 348 | """ |
349 | 2013-01-01 open Assets:Account1 | 349 | 2013-01-01 open Assets:Account1 |
@@ -363,7 +363,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
363 | Assets:Other -780000 USD | 363 | Assets:Other -780000 USD |
364 | """, new_entries) | 364 | """, new_entries) |
365 | 365 | ||
366 | @loader.load_doc() | 366 | @load_doc() |
367 | def test_add_implicit_prices__disabled(self, entries, errors, options_map): | 367 | def test_add_implicit_prices__disabled(self, entries, errors, options_map): |
368 | """ | 368 | """ |
369 | 2013-01-01 commodity HOOL | 369 | 2013-01-01 commodity HOOL |
@@ -389,7 +389,7 @@ class TestImplicitPrices(cmptest.TestCase): | |||
389 | Assets:Other -780000 USD | 389 | Assets:Other -780000 USD |
390 | """, new_entries) | 390 | """, new_entries) |
391 | 391 | ||
392 | @loader.load_doc() | 392 | @load_doc() |
393 | def test_add_implicit_prices__invalid(self, entries, errors, options_map): | 393 | def test_add_implicit_prices__invalid(self, entries, errors, options_map): |
394 | """ | 394 | """ |
395 | 2013-01-01 commodity HOOL | 395 | 2013-01-01 commodity HOOL |
diff --git a/beancount_extras_kris7t/plugins/templates_test.py b/beancount_extras_kris7t/plugins/templates_test.py index 5f63e6c..a786ccf 100644 --- a/beancount_extras_kris7t/plugins/templates_test.py +++ b/beancount_extras_kris7t/plugins/templates_test.py | |||
@@ -3,14 +3,15 @@ __license__ = 'GNU GPLv2' | |||
3 | 3 | ||
4 | import unittest | 4 | import unittest |
5 | 5 | ||
6 | from beancount import loader | 6 | from beancount.loader import load_doc |
7 | from beancount.parser import cmptest | 7 | from beancount.parser import cmptest |
8 | |||
8 | import pytest | 9 | import pytest |
9 | 10 | ||
10 | 11 | ||
11 | class TestClosingBalance(cmptest.TestCase): | 12 | class TestClosingBalance(cmptest.TestCase): |
12 | 13 | ||
13 | @loader.load_doc() | 14 | @load_doc() |
14 | def test_use_template_simple(self, entries, errors, options_map): | 15 | def test_use_template_simple(self, entries, errors, options_map): |
15 | ''' | 16 | ''' |
16 | plugin "beancount_extras_kris7t.plugins.templates" | 17 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -44,7 +45,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
44 | Expenses:Food -25 USD | 45 | Expenses:Food -25 USD |
45 | ''', entries) | 46 | ''', entries) |
46 | 47 | ||
47 | @loader.load_doc() | 48 | @load_doc() |
48 | def test_use_template_metadata(self, entries, errors, options_map): | 49 | def test_use_template_metadata(self, entries, errors, options_map): |
49 | ''' | 50 | ''' |
50 | plugin "beancount_extras_kris7t.plugins.templates" | 51 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -78,7 +79,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
78 | Expenses:Food -25 USD | 79 | Expenses:Food -25 USD |
79 | ''', entries) | 80 | ''', entries) |
80 | 81 | ||
81 | @loader.load_doc() | 82 | @load_doc() |
82 | def test_use_template_scaled(self, entries, errors, options_map): | 83 | def test_use_template_scaled(self, entries, errors, options_map): |
83 | ''' | 84 | ''' |
84 | plugin "beancount_extras_kris7t.plugins.templates" | 85 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -112,7 +113,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
112 | Expenses:Food -27 USD | 113 | Expenses:Food -27 USD |
113 | ''', entries) | 114 | ''', entries) |
114 | 115 | ||
115 | @loader.load_doc() | 116 | @load_doc() |
116 | def test_use_template_overwritten(self, entries, errors, options_map): | 117 | def test_use_template_overwritten(self, entries, errors, options_map): |
117 | ''' | 118 | ''' |
118 | plugin "beancount_extras_kris7t.plugins.templates" | 119 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -155,7 +156,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
155 | Expenses:Tax -2.70 USD | 156 | Expenses:Tax -2.70 USD |
156 | ''', entries) | 157 | ''', entries) |
157 | 158 | ||
158 | @loader.load_doc(expect_errors=True) | 159 | @load_doc(expect_errors=True) |
159 | def test_invalid_name(self, entries, errors, options_map): | 160 | def test_invalid_name(self, entries, errors, options_map): |
160 | ''' | 161 | ''' |
161 | plugin "beancount_extras_kris7t.plugins.templates" | 162 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -171,7 +172,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
171 | self.assertRegex(errors[0].message, "^template must be a string") | 172 | self.assertRegex(errors[0].message, "^template must be a string") |
172 | 173 | ||
173 | @pytest.mark.xfail(reason="Empty custom directive fails in beancount.ops.pad") | 174 | @pytest.mark.xfail(reason="Empty custom directive fails in beancount.ops.pad") |
174 | @loader.load_doc(expect_errors=True) | 175 | @load_doc(expect_errors=True) |
175 | def test_use_missing_name(self, entries, errors, options_map): | 176 | def test_use_missing_name(self, entries, errors, options_map): |
176 | ''' | 177 | ''' |
177 | plugin "beancount_extras_kris7t.plugins.templates" | 178 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -188,7 +189,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
188 | ''' | 189 | ''' |
189 | self.assertRegex(errors[0].message, "^Template name missing") | 190 | self.assertRegex(errors[0].message, "^Template name missing") |
190 | 191 | ||
191 | @loader.load_doc(expect_errors=True) | 192 | @load_doc(expect_errors=True) |
192 | def test_use_too_many_arguments(self, entries, errors, options_map): | 193 | def test_use_too_many_arguments(self, entries, errors, options_map): |
193 | ''' | 194 | ''' |
194 | plugin "beancount_extras_kris7t.plugins.templates" | 195 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -205,7 +206,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
205 | ''' | 206 | ''' |
206 | self.assertRegex(errors[0].message, "^Too many template-use arguments") | 207 | self.assertRegex(errors[0].message, "^Too many template-use arguments") |
207 | 208 | ||
208 | @loader.load_doc(expect_errors=True) | 209 | @load_doc(expect_errors=True) |
209 | def test_use_invalid_name(self, entries, errors, options_map): | 210 | def test_use_invalid_name(self, entries, errors, options_map): |
210 | ''' | 211 | ''' |
211 | plugin "beancount_extras_kris7t.plugins.templates" | 212 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -214,7 +215,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
214 | ''' | 215 | ''' |
215 | self.assertRegex(errors[0].message, "^Template name must be a string") | 216 | self.assertRegex(errors[0].message, "^Template name must be a string") |
216 | 217 | ||
217 | @loader.load_doc(expect_errors=True) | 218 | @load_doc(expect_errors=True) |
218 | def test_use_unknown(self, entries, errors, options_map): | 219 | def test_use_unknown(self, entries, errors, options_map): |
219 | ''' | 220 | ''' |
220 | plugin "beancount_extras_kris7t.plugins.templates" | 221 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -223,7 +224,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
223 | ''' | 224 | ''' |
224 | self.assertRegex(errors[0].message, "^Unknown template") | 225 | self.assertRegex(errors[0].message, "^Unknown template") |
225 | 226 | ||
226 | @loader.load_doc(expect_errors=True) | 227 | @load_doc(expect_errors=True) |
227 | def test_use_invalid_scale_factor(self, entries, errors, options_map): | 228 | def test_use_invalid_scale_factor(self, entries, errors, options_map): |
228 | ''' | 229 | ''' |
229 | plugin "beancount_extras_kris7t.plugins.templates" | 230 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -240,7 +241,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
240 | ''' | 241 | ''' |
241 | self.assertRegex(errors[0].message, "^Invalid scale factor") | 242 | self.assertRegex(errors[0].message, "^Invalid scale factor") |
242 | 243 | ||
243 | @loader.load_doc(expect_errors=True) | 244 | @load_doc(expect_errors=True) |
244 | def test_use_zero_scale_factor(self, entries, errors, options_map): | 245 | def test_use_zero_scale_factor(self, entries, errors, options_map): |
245 | ''' | 246 | ''' |
246 | plugin "beancount_extras_kris7t.plugins.templates" | 247 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -257,7 +258,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
257 | ''' | 258 | ''' |
258 | self.assertRegex(errors[0].message, "^Scale factor must not be 0") | 259 | self.assertRegex(errors[0].message, "^Scale factor must not be 0") |
259 | 260 | ||
260 | @loader.load_doc(expect_errors=True) | 261 | @load_doc(expect_errors=True) |
261 | def test_template_delete(self, entries, errors, options_map): | 262 | def test_template_delete(self, entries, errors, options_map): |
262 | ''' | 263 | ''' |
263 | plugin "beancount_extras_kris7t.plugins.templates" | 264 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -277,7 +278,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
277 | self.assertRegex(errors[0].message, "^Unknown template") | 278 | self.assertRegex(errors[0].message, "^Unknown template") |
278 | 279 | ||
279 | @pytest.mark.xfail(reason="Empty custom directive fails in beancount.ops.pad") | 280 | @pytest.mark.xfail(reason="Empty custom directive fails in beancount.ops.pad") |
280 | @loader.load_doc(expect_errors=True) | 281 | @load_doc(expect_errors=True) |
281 | def test_template_delete_too_few_arguments(self, entries, errors, options_map): | 282 | def test_template_delete_too_few_arguments(self, entries, errors, options_map): |
282 | ''' | 283 | ''' |
283 | plugin "beancount_extras_kris7t.plugins.templates" | 284 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -286,7 +287,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
286 | ''' | 287 | ''' |
287 | self.assertRegex(errors[0].message, "^template-delete takes a single argument") | 288 | self.assertRegex(errors[0].message, "^template-delete takes a single argument") |
288 | 289 | ||
289 | @loader.load_doc(expect_errors=True) | 290 | @load_doc(expect_errors=True) |
290 | def test_template_delete_too_many_arguments(self, entries, errors, options_map): | 291 | def test_template_delete_too_many_arguments(self, entries, errors, options_map): |
291 | ''' | 292 | ''' |
292 | plugin "beancount_extras_kris7t.plugins.templates" | 293 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -303,7 +304,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
303 | ''' | 304 | ''' |
304 | self.assertRegex(errors[0].message, "^template-delete takes a single argument") | 305 | self.assertRegex(errors[0].message, "^template-delete takes a single argument") |
305 | 306 | ||
306 | @loader.load_doc(expect_errors=True) | 307 | @load_doc(expect_errors=True) |
307 | def test_template_delete_invalid_argument(self, entries, errors, options_map): | 308 | def test_template_delete_invalid_argument(self, entries, errors, options_map): |
308 | ''' | 309 | ''' |
309 | plugin "beancount_extras_kris7t.plugins.templates" | 310 | plugin "beancount_extras_kris7t.plugins.templates" |
@@ -312,7 +313,7 @@ class TestClosingBalance(cmptest.TestCase): | |||
312 | ''' | 313 | ''' |
313 | self.assertRegex(errors[0].message, "^Template name must be a string") | 314 | self.assertRegex(errors[0].message, "^Template name must be a string") |
314 | 315 | ||
315 | @loader.load_doc(expect_errors=True) | 316 | @load_doc(expect_errors=True) |
316 | def test_template_delete_unknown(self, entries, errors, options_map): | 317 | def test_template_delete_unknown(self, entries, errors, options_map): |
317 | ''' | 318 | ''' |
318 | plugin "beancount_extras_kris7t.plugins.templates" | 319 | plugin "beancount_extras_kris7t.plugins.templates" |
diff --git a/beancount_extras_kris7t/plugins/transfer_accounts_test.py b/beancount_extras_kris7t/plugins/transfer_accounts_test.py index 0883522..a80b70c 100644 --- a/beancount_extras_kris7t/plugins/transfer_accounts_test.py +++ b/beancount_extras_kris7t/plugins/transfer_accounts_test.py | |||
@@ -3,13 +3,13 @@ __license__ = 'GNU GPLv2' | |||
3 | 3 | ||
4 | import unittest | 4 | import unittest |
5 | 5 | ||
6 | from beancount import loader | 6 | from beancount.loader import load_doc |
7 | from beancount.parser import cmptest | 7 | from beancount.parser import cmptest |
8 | 8 | ||
9 | 9 | ||
10 | class TestTransferAccounts(cmptest.TestCase): | 10 | class TestTransferAccounts(cmptest.TestCase): |
11 | 11 | ||
12 | @loader.load_doc() | 12 | @load_doc() |
13 | def test_same_currency(self, entries, _, __): | 13 | def test_same_currency(self, entries, _, __): |
14 | ''' | 14 | ''' |
15 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 15 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -40,7 +40,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
40 | Liabilities:CreditCard -20 USD | 40 | Liabilities:CreditCard -20 USD |
41 | ''', entries) | 41 | ''', entries) |
42 | 42 | ||
43 | @loader.load_doc() | 43 | @load_doc() |
44 | def test_missing_date(self, entries, _, __): | 44 | def test_missing_date(self, entries, _, __): |
45 | ''' | 45 | ''' |
46 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 46 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -70,7 +70,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
70 | Liabilities:CreditCard -20 USD | 70 | Liabilities:CreditCard -20 USD |
71 | ''', entries) | 71 | ''', entries) |
72 | 72 | ||
73 | @loader.load_doc(expect_errors=True) | 73 | @load_doc(expect_errors=True) |
74 | def test_missing_account_with_date(self, _, errors, __): | 74 | def test_missing_account_with_date(self, _, errors, __): |
75 | ''' | 75 | ''' |
76 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 76 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -86,7 +86,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
86 | ''' | 86 | ''' |
87 | self.assertRegex(errors[0].message, 'transfer-date was set but transfer-account was not') | 87 | self.assertRegex(errors[0].message, 'transfer-date was set but transfer-account was not') |
88 | 88 | ||
89 | @loader.load_doc(expect_errors=True) | 89 | @load_doc(expect_errors=True) |
90 | def test_missing_account_with_conversion(self, _, errors, __): | 90 | def test_missing_account_with_conversion(self, _, errors, __): |
91 | ''' | 91 | ''' |
92 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 92 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -103,7 +103,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
103 | self.assertRegex( | 103 | self.assertRegex( |
104 | errors[0].message, 'transfer-converted was set but transfer-account was not') | 104 | errors[0].message, 'transfer-converted was set but transfer-account was not') |
105 | 105 | ||
106 | @loader.load_doc(expect_errors=True) | 106 | @load_doc(expect_errors=True) |
107 | def test_invalid_account(self, _, errors, __): | 107 | def test_invalid_account(self, _, errors, __): |
108 | ''' | 108 | ''' |
109 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 109 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -119,7 +119,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
119 | ''' | 119 | ''' |
120 | self.assertRegex(errors[0].message, 'transfer-account must be a string.*') | 120 | self.assertRegex(errors[0].message, 'transfer-account must be a string.*') |
121 | 121 | ||
122 | @loader.load_doc(expect_errors=True) | 122 | @load_doc(expect_errors=True) |
123 | def test_invalid_date(self, _, errors, __): | 123 | def test_invalid_date(self, _, errors, __): |
124 | ''' | 124 | ''' |
125 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 125 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -136,7 +136,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
136 | ''' | 136 | ''' |
137 | self.assertRegex(errors[0].message, 'transfer-date must be a date.*') | 137 | self.assertRegex(errors[0].message, 'transfer-date must be a date.*') |
138 | 138 | ||
139 | @loader.load_doc(expect_errors=True) | 139 | @load_doc(expect_errors=True) |
140 | def test_invalid_conversion(self, _, errors, __): | 140 | def test_invalid_conversion(self, _, errors, __): |
141 | ''' | 141 | ''' |
142 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 142 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -153,7 +153,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
153 | ''' | 153 | ''' |
154 | self.assertRegex(errors[0].message, 'transfer-converted must be a Boolean.*') | 154 | self.assertRegex(errors[0].message, 'transfer-converted must be a Boolean.*') |
155 | 155 | ||
156 | @loader.load_doc(expect_errors=True) | 156 | @load_doc(expect_errors=True) |
157 | def test_invalid_account_conversion(self, _, errors, __): | 157 | def test_invalid_account_conversion(self, _, errors, __): |
158 | ''' | 158 | ''' |
159 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 159 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -163,7 +163,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
163 | ''' | 163 | ''' |
164 | self.assertRegex(errors[0].message, 'transfer-converted must be a Boolean.*') | 164 | self.assertRegex(errors[0].message, 'transfer-converted must be a Boolean.*') |
165 | 165 | ||
166 | @loader.load_doc(expect_errors=True) | 166 | @load_doc(expect_errors=True) |
167 | def test_redundant_conversion(self, _, errors, __): | 167 | def test_redundant_conversion(self, _, errors, __): |
168 | ''' | 168 | ''' |
169 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 169 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -181,7 +181,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
181 | self.assertRegex( | 181 | self.assertRegex( |
182 | errors[0].message, 'transfer-converted was set, but there is no conversion.*') | 182 | errors[0].message, 'transfer-converted was set, but there is no conversion.*') |
183 | 183 | ||
184 | @loader.load_doc() | 184 | @load_doc() |
185 | def test_converted_price_false(self, entries, _, __): | 185 | def test_converted_price_false(self, entries, _, __): |
186 | ''' | 186 | ''' |
187 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 187 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -213,7 +213,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
213 | Liabilities:CreditCard -25.60 CAD | 213 | Liabilities:CreditCard -25.60 CAD |
214 | ''', entries) | 214 | ''', entries) |
215 | 215 | ||
216 | @loader.load_doc() | 216 | @load_doc() |
217 | def test_converted_price_true(self, entries, _, __): | 217 | def test_converted_price_true(self, entries, _, __): |
218 | ''' | 218 | ''' |
219 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 219 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -245,7 +245,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
245 | Liabilities:CreditCard -20 USD | 245 | Liabilities:CreditCard -20 USD |
246 | ''', entries) | 246 | ''', entries) |
247 | 247 | ||
248 | @loader.load_doc() | 248 | @load_doc() |
249 | def test_converted_price_default(self, entries, _, __): | 249 | def test_converted_price_default(self, entries, _, __): |
250 | ''' | 250 | ''' |
251 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 251 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -276,7 +276,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
276 | Liabilities:CreditCard -20 USD | 276 | Liabilities:CreditCard -20 USD |
277 | ''', entries) | 277 | ''', entries) |
278 | 278 | ||
279 | @loader.load_doc() | 279 | @load_doc() |
280 | def test_converted_price_account_false(self, entries, _, __): | 280 | def test_converted_price_account_false(self, entries, _, __): |
281 | ''' | 281 | ''' |
282 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 282 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -308,7 +308,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
308 | Liabilities:CreditCard -25.60 CAD | 308 | Liabilities:CreditCard -25.60 CAD |
309 | ''', entries) | 309 | ''', entries) |
310 | 310 | ||
311 | @loader.load_doc() | 311 | @load_doc() |
312 | def test_converted_price_account_true(self, entries, _, __): | 312 | def test_converted_price_account_true(self, entries, _, __): |
313 | ''' | 313 | ''' |
314 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 314 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -340,7 +340,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
340 | Liabilities:CreditCard -20 USD | 340 | Liabilities:CreditCard -20 USD |
341 | ''', entries) | 341 | ''', entries) |
342 | 342 | ||
343 | @loader.load_doc() | 343 | @load_doc() |
344 | def test_converted_cost_false(self, entries, _, __): | 344 | def test_converted_cost_false(self, entries, _, __): |
345 | ''' | 345 | ''' |
346 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 346 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -372,7 +372,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
372 | Liabilities:CreditCard -25.60 CAD | 372 | Liabilities:CreditCard -25.60 CAD |
373 | ''', entries) | 373 | ''', entries) |
374 | 374 | ||
375 | @loader.load_doc() | 375 | @load_doc() |
376 | def test_converted_cost_true(self, entries, _, __): | 376 | def test_converted_cost_true(self, entries, _, __): |
377 | ''' | 377 | ''' |
378 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 378 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -404,7 +404,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
404 | Liabilities:CreditCard -20 USD {1.28 CAD, 2020-03-15} | 404 | Liabilities:CreditCard -20 USD {1.28 CAD, 2020-03-15} |
405 | ''', entries) | 405 | ''', entries) |
406 | 406 | ||
407 | @loader.load_doc() | 407 | @load_doc() |
408 | def test_converted_cost_and_price_false(self, entries, _, __): | 408 | def test_converted_cost_and_price_false(self, entries, _, __): |
409 | ''' | 409 | ''' |
410 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 410 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -436,7 +436,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
436 | Liabilities:CreditCard -25.60 CAD | 436 | Liabilities:CreditCard -25.60 CAD |
437 | ''', entries) | 437 | ''', entries) |
438 | 438 | ||
439 | @loader.load_doc() | 439 | @load_doc() |
440 | def test_converted_cost_and_price_true(self, entries, _, __): | 440 | def test_converted_cost_and_price_true(self, entries, _, __): |
441 | ''' | 441 | ''' |
442 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 442 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -468,7 +468,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
468 | Liabilities:CreditCard -20 USD {1.28 CAD, 2020-03-15} | 468 | Liabilities:CreditCard -20 USD {1.28 CAD, 2020-03-15} |
469 | ''', entries) | 469 | ''', entries) |
470 | 470 | ||
471 | @loader.load_doc() | 471 | @load_doc() |
472 | def test_multiple_separate(self, entries, _, __): | 472 | def test_multiple_separate(self, entries, _, __): |
473 | ''' | 473 | ''' |
474 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 474 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -508,7 +508,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
508 | Liabilities:CreditCard -25 USD | 508 | Liabilities:CreditCard -25 USD |
509 | ''', entries) | 509 | ''', entries) |
510 | 510 | ||
511 | @loader.load_doc() | 511 | @load_doc() |
512 | def test_multiple_merge(self, entries, _, __): | 512 | def test_multiple_merge(self, entries, _, __): |
513 | ''' | 513 | ''' |
514 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 514 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -545,7 +545,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
545 | Liabilities:CreditCard -45 USD | 545 | Liabilities:CreditCard -45 USD |
546 | ''', entries) | 546 | ''', entries) |
547 | 547 | ||
548 | @loader.load_doc() | 548 | @load_doc() |
549 | def test_multiple_currencies_merge_converted_false(self, entries, _, __): | 549 | def test_multiple_currencies_merge_converted_false(self, entries, _, __): |
550 | ''' | 550 | ''' |
551 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 551 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |
@@ -583,7 +583,7 @@ class TestTransferAccounts(cmptest.TestCase): | |||
583 | Liabilities:CreditCard -50.60 CAD | 583 | Liabilities:CreditCard -50.60 CAD |
584 | ''', entries) | 584 | ''', entries) |
585 | 585 | ||
586 | @loader.load_doc() | 586 | @load_doc() |
587 | def test_multiple_currencies_merge_converted_true(self, entries, _, __): | 587 | def test_multiple_currencies_merge_converted_true(self, entries, _, __): |
588 | ''' | 588 | ''' |
589 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" | 589 | plugin "beancount_extras_kris7t.plugins.transfer_accounts" |