blob: 9d5d9b8d75aef0bae084791cfb61b5a312f08ca1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
from gui.tasks.duration import format, parse
def test_format():
assert format(0) == ""
assert format(0.5) == "0.5m"
assert format(35) == "35m"
assert format(60) == "1h"
assert format(61) == "1h"
assert format(90) == "1.5h"
assert format(1440) == "1d"
def test_parse():
assert parse("") == 0
assert parse("42") == None
assert parse("hey") == None
assert parse("1h30") == None
assert parse("1h30m") == None
assert parse("17m") == 17
assert parse("90m") == 90
assert parse("1.5h") == 90
assert parse("2d") == 2880
|