diff options
Diffstat (limited to 'beancount_extras_kris7t/plugins/templates_test.py')
-rw-r--r-- | beancount_extras_kris7t/plugins/templates_test.py | 35 |
1 files changed, 18 insertions, 17 deletions
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" |