Commit be6a1965 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge pull request #75 from mruwek/importance-test

Test ignore_weekends clause in Importance
parents b76b1dbd 5b3784a7
...@@ -37,7 +37,7 @@ setup( ...@@ -37,7 +37,7 @@ setup(
':python_version=="2.7"': ['ushlex'], ':python_version=="2.7"': ['ushlex'],
'ical': ['icalendar'], 'ical': ['icalendar'],
'prompt-toolkit': ['prompt-toolkit >= 0.53'], 'prompt-toolkit': ['prompt-toolkit >= 0.53'],
'test': ['green', 'coverage'], 'test': ['freezegun', 'coverage', 'green'],
'test:python_version=="2.7"': ['mock'], 'test:python_version=="2.7"': ['mock'],
'test:python_version!="3.2"': ['pylint'], 'test:python_version!="3.2"': ['pylint'],
}, },
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import unittest import unittest
from datetime import date, timedelta from datetime import date, timedelta
from freezegun import freeze_time
from test.topydo_testcase import TopydoTest from test.topydo_testcase import TopydoTest
from topydo.lib.Config import config from topydo.lib.Config import config
...@@ -23,35 +24,37 @@ from topydo.lib.Importance import importance ...@@ -23,35 +24,37 @@ from topydo.lib.Importance import importance
from topydo.lib.Todo import Todo from topydo.lib.Todo import Todo
@freeze_time("2015, 11, 06")
class ImportanceTest(TopydoTest): class ImportanceTest(TopydoTest):
def test_importance1(self): def test_importance01(self):
todo = Todo("Foo") todo = Todo("Foo")
self.assertEqual(importance(todo), 2) self.assertEqual(importance(todo), 2)
def test_importance2(self): def test_importance02(self):
todo = Todo("(A) Foo") todo = Todo("(A) Foo")
self.assertEqual(importance(todo), 5) self.assertEqual(importance(todo), 5)
def test_importance3(self): def test_importance03(self):
todo = Todo("(A) Foo " + config().tag_star() + ":1") todo = Todo("(A) Foo " + config().tag_star() + ":1")
self.assertEqual(importance(todo), 6) self.assertEqual(importance(todo), 6)
def test_importance4(self): def test_importance04(self):
today_str = date.today().isoformat() today_str = date.today().isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str) todo = Todo("(C) Foo " + config().tag_due() + ":" + today_str)
self.assertEqual(importance(todo), 8) self.assertEqual(importance(todo), 8)
def test_importance5(self): def test_importance05(self):
due = date.today() + timedelta(8) todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-14")
due_str = due.isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + due_str)
self.assertEqual(importance(todo), 4) self.assertEqual(importance(todo), 4)
def test_importance6(self): def test_importance06(self):
due = date.today() + timedelta(4) todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-10")
due_str = due.isoformat()
todo = Todo("(C) Foo " + config().tag_due() + ":" + due_str)
self.assertEqual(importance(todo), 5) self.assertEqual(importance(todo), 5)
def test_importance07(self):
config(p_overrides={('sort', 'ignore_weekends'): '1'})
todo = Todo("(C) Foo " + config().tag_due() + ":" + "2015-11-09")
self.assertEqual(importance(todo), 6)
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment