Changeset - 5b6831292401
[Not reviewed]
0 1 0
Brett Smith - 4 years ago 2020-06-20 13:11:01
brettcsmith@brettcsmith.org
tests: Add tests for Balance.copy() tolerance handling.

I wrote the changes to Balance.format() before the dependent changes to
Balance.copy(), so I was sort of counting on them to be implicitly
tested. But they should be explicit.
1 file changed with 19 insertions and 5 deletions:
0 comments (0 inline, 0 general)
tests/test_reports_balance.py
Show inline comments
...
 
@@ -345,11 +345,23 @@ def test_iadd_balance(mapping):
 
    expected = core.Balance(amounts_from_map(expect_numbers))
 
    assert balance == expected
 

	
 
def test_copy():
 
    amounts = frozenset(amounts_from_map({'USD': 10, 'EUR': '.001'}))
 
    # Use a ridiculous tolerance to test it doesn't matter.
 
    actual = core.Balance(amounts, 100).copy()
 
    assert frozenset(actual.values()) == amounts
 
@pytest.mark.parametrize('tolerance', TOLERANCES)
 
def test_copy(tolerance):
 
    eur = testutil.Amount('.003', 'EUR')
 
    source = core.Balance([eur], tolerance)
 
    new = source.copy()
 
    assert source is not new
 
    assert dict(source) == dict(new)
 
    assert new.tolerance == tolerance
 

	
 
@pytest.mark.parametrize('tolerance', TOLERANCES)
 
def test_copy_tolerance_arg(tolerance):
 
    eur = testutil.Amount('.003', 'EUR')
 
    source = core.Balance([eur])
 
    new = source.copy(tolerance)
 
    assert source is not new
 
    assert dict(source) == dict(new)
 
    assert new.tolerance == tolerance
 

	
 
@pytest.mark.parametrize('tolerance', TOLERANCES)
 
def test_clean_copy(tolerance):
...
 
@@ -361,6 +373,7 @@ def test_clean_copy(tolerance):
 
    else:
 
        expected = {usd}
 
    assert frozenset(actual.values()) == expected
 
    assert actual.tolerance == tolerance
 

	
 
@pytest.mark.parametrize('tolerance', TOLERANCES)
 
def test_clean_copy_arg(tolerance):
...
 
@@ -372,6 +385,7 @@ def test_clean_copy_arg(tolerance):
 
    else:
 
        expected = {usd}
 
    assert frozenset(actual.values()) == expected
 
    assert actual.tolerance == tolerance
 

	
 
@pytest.mark.parametrize('mapping,expected', DEFAULT_STRINGS)
 
def test_str(mapping, expected):
0 comments (0 inline, 0 general)