Changeset - 5601ece2ac43
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-06-04 13:15:23
brettcsmith@brettcsmith.org
tests: books.Loader tests do more bounds checking.
1 file changed with 9 insertions and 3 deletions:
0 comments (0 inline, 0 general)
tests/test_books_loader.py
Show inline comments
...
 
@@ -64,13 +64,15 @@ def txn_years(entries):
 
    (20, 2010, range(2018, 2021)),
 
    (-20, 2030, range(2018, 2021)),
 
])
 
def test_load_fy_range(conservancy_loader, from_fy, to_fy, expect_years):
 
    entries, errors, options_map = conservancy_loader.load_fy_range(from_fy, to_fy)
 
    assert not errors
 
    assert txn_years(entries).issuperset(expect_years)
 
    actual_years = txn_years(entries)
 
    assert actual_years.issuperset(expect_years)
 
    assert min(actual_years) == expect_years.start
 

	
 
def test_load_fy_range_does_not_duplicate_openings(conservancy_loader):
 
    entries, errors, options_map = conservancy_loader.load_fy_range(2010, 2030)
 
    check_openings(entries)
 

	
 
def test_load_fy_range_empty(conservancy_loader):
...
 
@@ -82,13 +84,15 @@ def test_load_fy_range_empty(conservancy_loader):
 
@pytest.mark.parametrize('from_year', [None, *range(2018, 2021)])
 
def test_load_all(conservancy_loader, from_year):
 
    entries, errors, options_map = conservancy_loader.load_all(from_year)
 
    from_year = from_year or 2018
 
    assert not errors
 
    check_openings(entries)
 
    assert txn_years(entries).issuperset(range(from_year or 2018, 2021))
 
    actual_years = txn_years(entries)
 
    assert actual_years.issuperset(range(from_year, 2021))
 
    assert min(actual_years) == from_year
 

	
 
@pytest.mark.parametrize('from_date', [
 
    date(2019, 2, 1),
 
    date(2019, 9, 15),
 
    date(2020, 1, 20),
 
    date(2020, 5, 31),
...
 
@@ -97,7 +101,9 @@ def test_load_all_from_date(conservancy_loader, from_date):
 
    from_year = from_date.year
 
    if from_date.month < FY_START_MONTH:
 
        from_year -= 1
 
    entries, errors, options_map = conservancy_loader.load_all(from_date)
 
    assert not errors
 
    check_openings(entries)
 
    assert txn_years(entries).issuperset(range(from_year, 2021))
 
    actual_years = txn_years(entries)
 
    assert actual_years.issuperset(range(from_year, 2021))
 
    assert min(actual_years) == from_year
0 comments (0 inline, 0 general)