diff options
author | Joris | 2020-06-06 10:09:27 +0200 |
---|---|---|
committer | Joris | 2020-06-06 10:09:27 +0200 |
commit | 6b9195000eb5404c247288b384d7ca2bacc1ab23 (patch) | |
tree | d36d669b70d2a5f2789335e814489cd641fbae3e /src/gui | |
parent | b244640288648f27ce1fc7be3f175703e0a3412b (diff) |
Add unit tests
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/tasks/test_duration.py | 21 |
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 |