aboutsummaryrefslogtreecommitdiff
path: root/src/gui/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/tasks')
-rw-r--r--src/gui/tasks/test_duration.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/gui/tasks/test_duration.py b/src/gui/tasks/test_duration.py
new file mode 100644
index 0000000..9d5d9b8
--- /dev/null
+++ b/src/gui/tasks/test_duration.py
@@ -0,0 +1,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