diff --git a/oxrlib/commands/historical.py b/oxrlib/commands/historical.py index 71ba00e9934c6478a35fa4163b096076435c56d0..0e578874423938c75acec7ac5d4b00118b176e60 100644 --- a/oxrlib/commands/historical.py +++ b/oxrlib/commands/historical.py @@ -185,11 +185,13 @@ def load_rates(config, loaders, date): def run(config, stdout, stderr): loaders = config.get_loaders() - cost_rates = load_rates(config, loaders, config.args.date) + date_rates = load_rates(config, loaders, config.args.date) if config.args.from_date is None: + cost_rates = date_rates price_rates = None else: - price_rates = load_rates(config, loaders, config.args.from_date) + cost_rates = load_rates(config, loaders, config.args.from_date) + price_rates = date_rates formatter = config.args.output_format.value( cost_rates, price_rates, diff --git a/setup.py b/setup.py index 623d196752690f3e6866385cc0112ef864716dbb..bd078fa5df9f4e110f75a12e5d2d8c61d73b1c8c 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup setup( name='oxrlib', description="Library to query the Open Exchange Rates (OXR) API", - version='2.1', + version='2.2', author='Brett Smith', author_email='brettcsmith@brettcsmith.org', license='GNU AGPLv3+', diff --git a/tests/test_historical.py b/tests/test_historical.py index e226c8e1055bbead0c5cd0c04e279546ae754b6a..49a81c34f55babb9fd596bd37ef42e0e576f7ded 100644 --- a/tests/test_historical.py +++ b/tests/test_historical.py @@ -225,8 +225,8 @@ def test_from_date_rates(alternate_responder, output, any_date, output_format): from_date=any_date, output_format=output_format, denomination='USD') lines = lines_from_run(config, output) - check_fx_amount(config, lines, '1 ANG', '2.051', 'AED', None, '1.909') - check_fx_amount(config, lines, '1 AED', '0.487', 'ANG', None, '0.523') + check_fx_amount(config, lines, '1 ANG', '1.909', 'AED', None, '2.051') + check_fx_amount(config, lines, '1 AED', '0.523', 'ANG', None, '0.487') assert next(lines, None) is None @parametrize_format @@ -236,8 +236,8 @@ def test_from_date_conversion(alternate_responder, output, any_date, output_form from_date=any_date, output_format=output_format, denomination='USD') lines = lines_from_run(config, output) - check_fx_amount(config, lines, '10.00 ANG', '0.558', 'USD', '$', '0.507') - check_fx_amount(config, lines, '20.52 AED', '0.272', 'USD', '$', '0.265') + check_fx_amount(config, lines, '10.00 ANG', '0.507', 'USD', '$', '0.558') + check_fx_amount(config, lines, '19.10 AED', '0.265', 'USD', '$', '0.272') assert next(lines, None) is None @parametrize_format @@ -252,11 +252,10 @@ def test_rate_consistent_as_cost_and_price(alternate_responder, any_date, output config = build_config(date=any_date, **config_kwargs) with io.StringIO() as output: lines = lines_from_run(config, output) - match = re.search(r'\{=?(\d+\.\d+ USD)\}', next(lines, "")) - assert match - expect_rate = f' @ {match.group(1)}\n' + match = re.search(r'\{=?\d+\.\d+ USD\}', next(lines, "")) + assert match is not None future_date = any_date.replace(year=any_date.year + 1) config = build_config(date=future_date, from_date=any_date, **config_kwargs) with io.StringIO() as output: lines = lines_from_run(config, output) - assert next(lines, "").endswith(expect_rate) + assert match.group(0) in next(lines, "")