test: add format_duration test

This commit is contained in:
Matthias
2025-05-20 18:15:54 +02:00
parent 882ca44816
commit 947cbdd858

View File

@@ -1,5 +1,6 @@
from freqtrade.util import decimals_per_coin, fmt_coin, round_value
from freqtrade.util.formatters import fmt_coin2
from datetime import timedelta
from freqtrade.util import decimals_per_coin, fmt_coin, fmt_coin2, format_duration, round_value
def test_decimals_per_coin():
@@ -45,3 +46,12 @@ def test_round_value():
assert round_value(0.1274512123, 5) == "0.12745"
assert round_value(222.2, 3, True) == "222.200"
assert round_value(222.2, 0, True) == "222"
def test_format_duration():
assert format_duration(timedelta(minutes=5)) == "0d 00:05"
assert format_duration(timedelta(minutes=75)) == "0d 01:15"
assert format_duration(timedelta(minutes=1440)) == "1d 00:00"
assert format_duration(timedelta(minutes=1445)) == "1d 00:05"
assert format_duration(timedelta(minutes=11445)) == "7d 22:45"
assert format_duration(timedelta(minutes=101445)) == "70d 10:45"