diff --git a/tests/test_historical.py b/tests/test_historical.py index 7eaf13a1ca71f97aeb12a5b904af0b3c743a3c92..d68b803ac228c6e80929be2e22316942558bbf8a 100644 --- a/tests/test_historical.py +++ b/tests/test_historical.py @@ -49,6 +49,7 @@ def build_config( to_currency=None, ledger=False, signed_currencies=None, + denomination=None, base='USD', ): return FakeConfig(responder, { @@ -59,6 +60,7 @@ def build_config( 'to_currency': base if to_currency is None else to_currency, 'ledger': ledger, 'signed_currencies': [base] if signed_currencies is None else signed_currencies, + 'denomination': denomination, }) def lines_from_run(config, output): @@ -117,3 +119,30 @@ def test_signed_currencies(historical1_responder, output): assert next(lines) == '1 AED {=0.2723 USD} @ 0.2723 USD\n' assert next(lines) == '1 USD {=3.67246 AED} @ 3.67246 AED\n' assert next(lines, None) is None + +def test_denomination(historical1_responder, output): + config = build_config(historical1_responder, from_currency='ANG', + to_currency='AED', amount=10, + ledger=True, denomination='USD') + lines = lines_from_run(config, output) + assert next(lines) == '10.00 ANG {=$0.55866} @ $0.55866\n' + assert next(lines) == '20.52 AED {=$0.2723} @ $0.2723\n' + assert next(lines, None) is None + +def test_redundant_denomination(historical1_responder, output): + config = build_config(historical1_responder, from_currency='ANG', + to_currency='USD', amount=10, + ledger=True, denomination='USD') + lines = lines_from_run(config, output) + assert next(lines) == '10.00 ANG {=$0.55866} @ $0.55866\n' + assert next(lines) == '$5.59\n' + assert next(lines, None) is None + +def test_from_denomination(historical1_responder, output): + config = build_config(historical1_responder, from_currency='USD', + to_currency='ALL', amount=10, + ledger=True, denomination='USD') + lines = lines_from_run(config, output) + assert next(lines) == '$10.00\n' + assert next(lines) == '1,445 ALL {=$0.006919} @ $0.006919\n' + assert next(lines, None) is None