Download:
child 36:63c9cb7c6bb8
parent 34:0a5f37c8562d
35:d0d03f67dc1f
Anton Shestakov <av6@dwimlabs.net>, Fri, 17 Jun 2016 21:23:45 +0800
tests: add test_models with some Check.get_duration() checks

4 файлов изменено, 29 вставок(+), 0 удалений(-) [+]
.hgignore file | annotate | diff | comparison | revisions
dev-requirements.txt file | annotate | diff | comparison | revisions
run-tests.py file | annotate | diff | comparison | revisions
tests/test_models.py file | annotate | diff | comparison | revisions
--- a/.hgignore Fri Jun 17 21:21:13 2016 +0800
+++ b/.hgignore Fri Jun 17 21:23:45 2016 +0800
@@ -2,4 +2,5 @@
*.pyc
venv/
+tests/.cache/
database.sqlite
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev-requirements.txt Fri Jun 17 21:23:45 2016 +0800
@@ -0,0 +1,1 @@
+pytest==2.9.2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/run-tests.py Fri Jun 17 21:23:45 2016 +0800
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import pytest
+
+
+def main():
+ pytest.main(['tests'])
+
+
+if __name__ == '__main__':
+ main()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test_models.py Fri Jun 17 21:23:45 2016 +0800
@@ -0,0 +1,17 @@
+from datetime import datetime, timedelta
+
+from candolint.models import Check
+
+
+def test_duration():
+ now = datetime.now()
+ check = Check(started=now)
+
+ check.finished = now + timedelta(seconds=10)
+ assert check.get_duration() == '10 sec'
+
+ check.finished = now + timedelta(minutes=5)
+ assert check.get_duration() == '5 min'
+
+ check.finished = now + timedelta(hours=2)
+ assert check.get_duration() == '120 min'