Improve timerange parsing when accepting values from API
This commit is contained in:
parent
c3647e49ad
commit
b892d373cd
@ -116,7 +116,7 @@ class TimeRange:
|
|||||||
:param text: value from --timerange
|
:param text: value from --timerange
|
||||||
:return: Start and End range period
|
:return: Start and End range period
|
||||||
"""
|
"""
|
||||||
if text is None:
|
if not text:
|
||||||
return TimeRange(None, None, 0, 0)
|
return TimeRange(None, None, 0, 0)
|
||||||
syntax = [(r'^-(\d{8})$', (None, 'date')),
|
syntax = [(r'^-(\d{8})$', (None, 'date')),
|
||||||
(r'^(\d{8})-$', ('date', None)),
|
(r'^(\d{8})-$', ('date', None)),
|
||||||
|
@ -10,6 +10,8 @@ from freqtrade.exceptions import OperationalException
|
|||||||
|
|
||||||
def test_parse_timerange_incorrect():
|
def test_parse_timerange_incorrect():
|
||||||
|
|
||||||
|
timerange = TimeRange.parse_timerange('')
|
||||||
|
assert timerange == TimeRange(None, None, 0, 0)
|
||||||
timerange = TimeRange.parse_timerange('20100522-')
|
timerange = TimeRange.parse_timerange('20100522-')
|
||||||
assert TimeRange('date', None, 1274486400, 0) == timerange
|
assert TimeRange('date', None, 1274486400, 0) == timerange
|
||||||
assert timerange.timerange_str == '20100522-'
|
assert timerange.timerange_str == '20100522-'
|
||||||
|
Loading…
Reference in New Issue
Block a user