From 270ccbb0dac9d4b996831721d9d5f4249e2ae173 Mon Sep 17 00:00:00 2001 From: xmatthias Date: Tue, 5 Jun 2018 23:41:50 +0200 Subject: [PATCH] fix args test --- freqtrade/tests/test_arguments.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/freqtrade/tests/test_arguments.py b/freqtrade/tests/test_arguments.py index 474aa2507..9c24a6789 100644 --- a/freqtrade/tests/test_arguments.py +++ b/freqtrade/tests/test_arguments.py @@ -9,7 +9,7 @@ import logging import pytest -from freqtrade.arguments import Arguments +from freqtrade.arguments import Arguments, TimeRange def test_arguments_object() -> None: @@ -107,20 +107,25 @@ def test_parse_args_dynamic_whitelist_invalid_values() -> None: def test_parse_timerange_incorrect() -> None: - assert ((None, 'line'), None, -200) == Arguments.parse_timerange('-200') - assert (('line', None), 200, None) == Arguments.parse_timerange('200-') - assert (('index', 'index'), 200, 500) == Arguments.parse_timerange('200-500') + assert TimeRange(None, 'line', 0, -200) == Arguments.parse_timerange('-200') + assert TimeRange('line', None, 200, 0) == Arguments.parse_timerange('200-') + assert TimeRange('index', 'index', 200, 500) == Arguments.parse_timerange('200-500') - assert (('date', None), 1274486400, None) == Arguments.parse_timerange('20100522-') - assert ((None, 'date'), None, 1274486400) == Arguments.parse_timerange('-20100522') + assert TimeRange('date', None, 1274486400, 0) == Arguments.parse_timerange('20100522-') + assert TimeRange(None, 'date', 0, 1274486400) == Arguments.parse_timerange('-20100522') timerange = Arguments.parse_timerange('20100522-20150730') - assert timerange == (('date', 'date'), 1274486400, 1438214400) + assert timerange == TimeRange('date', 'date', 1274486400, 1438214400) # Added test for unix timestamp - BTC genesis date - assert (('date', None), 1231006505, None) == Arguments.parse_timerange('1231006505-') - assert ((None, 'date'), None, 1233360000) == Arguments.parse_timerange('-1233360000') + assert TimeRange('date', None, 1231006505, 0) == Arguments.parse_timerange('1231006505-') + assert TimeRange(None, 'date', 0, 1233360000) == Arguments.parse_timerange('-1233360000') timerange = Arguments.parse_timerange('1231006505-1233360000') - assert timerange == (('date', 'date'), 1231006505, 1233360000) + assert TimeRange('date', 'date', 1231006505, 1233360000) == timerange + + # TODO: Find solution for the following case (passing timestamp in ms) + timerange = Arguments.parse_timerange('1231006505000-1233360000000') + assert TimeRange('date', 'date', 1231006505, 1233360000) != timerange + with pytest.raises(Exception, match=r'Incorrect syntax.*'): Arguments.parse_timerange('-')