Changeset - 3000aeee0918
[Not reviewed]
0 2 0
Brett Smith - 4 years ago 2020-04-21 17:35:56
brettcsmith@brettcsmith.org
config: Add Config.books_loader() method.
2 files changed with 18 insertions and 0 deletions:
0 comments (0 inline, 0 general)
conservancy_beancount/config.py
Show inline comments
...
 
@@ -113,2 +113,9 @@ class Config:
 

	
 
    def books_loader(self) -> Optional[books.Loader]:
 
        books_path = self.books_path()
 
        if books_path is None:
 
            return None
 
        else:
 
            return books.Loader(books_path, self.fiscal_year_begin())
 

	
 
    def books_path(self) -> Optional[Path]:
tests/test_config.py
Show inline comments
...
 
@@ -383 +383,12 @@ def test_default_fiscal_year_begin():
 
    assert actual.day == 1
 

	
 
def test_books_loader():
 
    books_path = testutil.test_path('bookstest')
 
    config = config_mod.Config()
 
    config.load_string(f'[Beancount]\nbooks dir = {books_path}\n')
 
    loader = config.books_loader()
 
    expected = 'include "{}"'.format(books_path / 'books/2020.beancount')
 
    assert loader.fy_range_string(0, 2020, {}) == expected
 

	
 
def test_books_loader_without_books():
 
    assert config_mod.Config().books_loader() is None
0 comments (0 inline, 0 general)