diff --git a/tests/test_historical.py b/tests/test_historical.py index 3becdba240954dcc11a39b0256e4a7d1394e34f8..7eaf13a1ca71f97aeb12a5b904af0b3c743a3c92 100644 --- a/tests/test_historical.py +++ b/tests/test_historical.py @@ -47,6 +47,8 @@ def build_config( amount=None, from_currency=None, to_currency=None, + ledger=False, + signed_currencies=None, base='USD', ): return FakeConfig(responder, { @@ -55,6 +57,8 @@ def build_config( 'amount': None if amount is None else decimal.Decimal(amount), 'from_currency': from_currency, 'to_currency': base if to_currency is None else to_currency, + 'ledger': ledger, + 'signed_currencies': [base] if signed_currencies is None else signed_currencies, }) def lines_from_run(config, output): @@ -91,3 +95,25 @@ def test_back_conversion(historical1_responder, output): lines = lines_from_run(config, output) assert next(lines) == '2.00 USD = 289 ALL\n' assert next(lines, None) is None + +def test_ledger_rate(historical1_responder, output): + config = build_config(historical1_responder, from_currency='ANG', ledger=True) + lines = lines_from_run(config, output) + assert next(lines) == '1 ANG {=$0.55866} @ $0.55866\n' + assert next(lines) == '1 USD {=1.79 ANG} @ 1.79 ANG\n' + assert next(lines, None) is None + +def test_ledger_conversion(historical1_responder, output): + config = build_config(historical1_responder, from_currency='ALL', amount=300, ledger=True) + lines = lines_from_run(config, output) + assert next(lines) == '300 ALL {=$0.006919} @ $0.006919\n' + assert next(lines) == '$2.08\n' + assert next(lines, None) is None + +def test_signed_currencies(historical1_responder, output): + config = build_config(historical1_responder, from_currency='AED', + ledger=True, signed_currencies=['EUR']) + lines = lines_from_run(config, 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