Changeset - 96a363633f5e
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-04-21 15:58:28
brettcsmith@brettcsmith.org
books: Add Loader.load_fy_range() method.
2 files changed with 28 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/books.py
Show inline comments
...
 
@@ -20,3 +20,6 @@ from pathlib import Path
 

	
 
from beancount import loader as bc_loader
 

	
 
from typing import (
 
    Any,
 
    Iterable,
...
 
@@ -27,2 +30,5 @@ from typing import (
 
)
 
from .beancount_types import (
 
    LoadResult,
 
)
 

	
...
 
@@ -149 +155,16 @@ class Loader:
 
        ])
 

	
 
    def load_fy_range(self,
 
                      from_fy: Year,
 
                      to_fy: Optional[Year]=None,
 
                      plugins: Optional[PluginsSpec]=None,
 
    ) -> LoadResult:
 
        """Load books for a range of fiscal years
 

	
 
        This is a convenience wrapper to call
 
        self.fy_range_string(from_fy, to_fy, plugins)
 
        and load the result with beancount.loader.load_string.
 
        """
 
        return bc_loader.load_string(  # type:ignore[no-untyped-call, no-any-return]
 
            self.fy_range_string(from_fy, to_fy, plugins),
 
        )
tests/test_books_loader.py
Show inline comments
...
 
@@ -16,2 +16,4 @@
 

	
 
import hashlib
 

	
 
from datetime import date
...
 
@@ -76 +78,6 @@ def test_fy_range_string_empty_range(conservancy_loader):
 
    assert conservancy_loader.fy_range_string(2020, 2019) == ''
 

	
 
def test_load_fy_range_empty(conservancy_loader):
 
    entries, errors, options_map = conservancy_loader.load_fy_range(2020, 2019)
 
    assert not entries
 
    assert options_map.get('input_hash') == hashlib.md5().hexdigest()
0 comments (0 inline, 0 general)