File diff 9b6d562d46f5 → 27dbe14b94eb
tests/test_Configuration.py
Show inline comments
...
 
@@ -46,26 +46,34 @@ def test_historical_default_base(ini_filename, expected_currency, use_switch, an
 
    config = config_from(ini_filename, arglist)
 
    assert config.args.base == expected_currency
 

	
 
@pytest.mark.parametrize('amount,from_curr,preposition,to_curr', [
 
    (None, 'JPY', None, None),
 
    (None, 'gbp', None, 'Aud'),
 
    (None, 'CHF', 'to', 'eur'),
 
    (decimal.Decimal('1000'), 'chf', None, None),
 
    (decimal.Decimal('999'), 'Eur', None, 'Chf'),
 
    (decimal.Decimal('12.34'), 'gbp', 'IN', 'eur'),
 
@pytest.mark.parametrize('amount,from_curr,prep1,to_curr,prep2,from_date', [
 
    (None, 'JPY', None, None, None, None),
 
    (None, 'gbp', None, 'Aud', None, None),
 
    (None, 'CHF', 'to', 'eur', None, None),
 
    (decimal.Decimal('1000'), 'chf', None, None, None, None),
 
    (decimal.Decimal('999'), 'Eur', None, 'Chf', None, None),
 
    (decimal.Decimal('12.34'), 'gbp', 'IN', 'eur', None, None),
 
    (None, 'JPY', None, None, None, '12-15'),
 
    (None, 'gbp', None, 'Aud', 'From', '12.15'),
 
    (None, 'CHF', 'to', 'eur', 'from', '15'),
 
    (decimal.Decimal('1000'), 'chf', None, None, None, '12-15'),
 
    (decimal.Decimal('999'), 'Eur', None, 'Chf', None, '2016.12.15'),
 
    (decimal.Decimal('12.34'), 'gbp', 'IN', 'eur', 'from', '2016-12-15'),
 
])
 
def test_historical_argparsing_success(amount, from_curr, preposition, to_curr, any_date):
 
def test_historical_argparsing_success(amount, from_curr, prep1, to_curr, prep2, from_date, any_date):
 
    oxrlib.config.Configuration.TODAY = datetime.date(2017, 1, 1)
 
    # This locale's currency should not be used in any test cases above.
 
    oxrlib.config.Configuration.LOCALE = babel.core.Locale('en', 'IN')
 
    arglist = ['historical', any_date.isoformat()]
 
    arglist.extend(str(s) for s in [amount, from_curr, preposition, to_curr]
 
    arglist.extend(str(s) for s in [amount, from_curr, prep1, to_curr, prep2, from_date]
 
                   if s is not None)
 
    config = config_from(os.devnull, arglist)
 
    expect_to_curr = 'INR' if to_curr is None else to_curr.upper()
 
    assert config.args.amount == amount
 
    assert config.args.from_currency == from_curr.upper()
 
    assert config.args.to_currency == expect_to_curr
 
    expect_from_date = None if from_date is None else datetime.date(2016, 12, 15)
 
    assert config.args.from_date == expect_from_date
 

	
 
@pytest.mark.parametrize('arglist', [
 
    ['100'],
...
 
@@ -76,6 +84,10 @@ def test_historical_argparsing_success(amount, from_curr, preposition, to_curr,
 
    ['44', 'eur', 'in', 'chf', 'pronto'],
 
    ['eur', 'into'],
 
    ['50', 'jpy', 'in'],
 
    ['115', 'usd', 'in', '12-15'],
 
    ['125', 'jpy', 'from', 'chf'],
 
    ['135', 'chf', 'eur', 'gbp'],
 
    ['145', 'brl', '12-16', '2020-12-18'],
 
])
 
def test_historical_argparsing_failure(arglist, any_date):
 
    arglist = ['historical', any_date.isoformat()] + arglist