@@ -83,48 +83,57 @@ def test_historical_argparsing_failure(arglist, any_date):
arglist = ['historical', any_date.isoformat()] + arglist
try:
config = config_from(os.devnull, arglist)
except SystemExit:
pass
else:
assert not vars(config.args), "bad arglist succeeded"
@pytest.mark.parametrize('date_s,expect_year,expect_month,expect_day', [
('5', 1965, 7, 5),
('05', 1965, 7, 5),
('14', 1965, 7, 14),
('15', 1965, 7, 15),
('16', 1965, 6, 16),
('3-6', 1965, 3, 6),
('11.10', 1964, 11, 10),
('07-14', 1965, 7, 14),
('07/15', 1965, 7, 15),
('7.16', 1964, 7, 16),
('917/12/12', 917, 12, 12),
('2017-11-1', 2017, 11, 1),
])
def test_good_date_parsing(date_s, expect_year, expect_month, expect_day):
oxrlib.config.Configuration.TODAY = datetime.date(1965, 7, 15)
config = config_from(os.devnull, ['historical', date_s])
actual_date = config.args.date
assert actual_date.year == expect_year
assert actual_date.month == expect_month
assert actual_date.day == expect_day
@pytest.mark.parametrize('date_s', [
'99',
'8-88',
'77-7',
'0xf-1-2',
'0b1-3-4',
'2017/5.9',
'2018-6/10',
'1-2-3-4',
'12/11/10',
def test_bad_date_parsing(date_s):
assert not config.args.date, "date parsed from {!r}".format(date_s)
def test_ambiguous_arglist_failure():
# It's ambiguous if "2" is "the 2nd" or "2 EUR".
config = config_from(os.devnull, ['historical', '2', 'eur'])
assert not config.args, "ambiguous args parsed"