From 6b9195000eb5404c247288b384d7ca2bacc1ab23 Mon Sep 17 00:00:00 2001 From: Joris Date: Sat, 6 Jun 2020 10:09:27 +0200 Subject: Add unit tests --- src/gui/tasks/test_duration.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/gui/tasks/test_duration.py (limited to 'src/gui/tasks') 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 -- cgit v1.2.3