Files
@ 667c214e9191
Branch filter:
Location: NPO-Accounting/oxrlib/tests/test_Configuration.py - annotation
667c214e9191
1.3 KiB
text/x-python
historical: Add main code for historical subcommand.
0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a 0120e4ce5a5a | import os
import pytest
from . import any_date, relpath
import oxrlib.config
import oxrlib.loaders
INI_DIR_PATH = relpath('config_ini')
def config_from(ini_filename, arglist=None):
if arglist is None:
arglist = ['historical', any_date().isoformat()]
ini_path = INI_DIR_PATH / ini_filename
return oxrlib.config.Configuration(['--config-file', ini_path.as_posix()] + arglist)
def test_full_config():
config = config_from('full.ini')
loaders = config.get_loaders().loaders
assert type(loaders[0]) is oxrlib.loaders.FileCache
assert type(loaders[1]) is oxrlib.loaders.OXRAPIRequest
assert len(loaders) == 2
def test_incomplete_config():
config = config_from('incomplete.ini')
assert not config.get_loaders().loaders
def test_empty_config():
config = config_from(os.devnull)
assert not config.get_loaders().loaders
@pytest.mark.parametrize('ini_filename,expected_currency,use_switch', [
(os.devnull, 'USD', False),
('full.ini', 'INI', False),
('full.ini', 'EUR', True),
])
def test_historical_default_base(ini_filename, expected_currency, use_switch, any_date):
arglist = ['historical']
if use_switch:
arglist.extend(['--base', expected_currency])
arglist.append(any_date.isoformat())
config = config_from(ini_filename, arglist)
assert config.args.base == expected_currency
|