def test_filter16(self): todos = load_file('test/data/FilterTest1.txt') grep = Filter.NegationFilter(Filter.GrepFilter('+project')) filtered_todos = grep.filter(todos) reference = load_file('test/data/FilterTest3-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter31(self): todos = load_file('test/data/FilterTest3.txt') otf = Filter.OrdinalTagFilter('value:>-8') filtered_todos = otf.filter(todos) reference = load_file('test/data/FilterTest13-result.txt') self.assertEqual(todolist_to_string(filtered_todos), todolist_to_string(reference))
def test_filter20(self): todos = load_file('test/data/FilterTest3.txt') otf = Filter.OrdinalTagFilter('due:<2014-11-10') filtered_todos = otf.filter(todos) reference = load_file('test/data/FilterTest6-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter5(self): """ Test case sensitive match. """ todos = load_file('test/data/FilterTest1.txt') grep = Filter.GrepFilter('+Project') filtered_todos = grep.filter(todos) reference = load_file('test/data/FilterTest1b-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter8(self): """ Test case sensitive match (forced, with lowercase). """ todos = load_file('test/data/FilterTest1.txt') grep = Filter.GrepFilter('+Project', False) filtered_todos = grep.filter(todos) reference = load_file('test/data/FilterTest1a-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter18(self): todos = load_file('test/data/FilterTest1.txt') grep1 = Filter.GrepFilter('part') grep2 = Filter.GrepFilter('important') grep = Filter.OrFilter(grep1, grep2) filtered_todos = grep.filter(todos) reference = load_file('test/data/FilterTest5-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter17(self): todos = load_file('test/data/FilterTest1.txt') grep1 = Filter.GrepFilter('task') grep2 = Filter.GrepFilter('project') andfilter = Filter.AndFilter(grep1, grep2) filtered_todos = andfilter.filter(todos) reference = load_file('test/data/FilterTest4-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def sort_file(self, p_filename, p_filename_ref, p_sorter): """ Sorts a file and compares it with a reference result. Also check that the sort algorithm hasn't touched the original data. """ todos = load_file(p_filename) text_before = todolist_to_string(todos) todos_sorted = todolist_to_string(p_sorter.sort(todos)) todos_ref = todolist_to_string(load_file(p_filename_ref)) self.assertEqual(todos_sorted, todos_ref) self.assertEqual(todolist_to_string(todos), text_before)
def test_filter23(self): todos = load_file('test/data/FilterTest3.txt') otf = Filter.OrdinalTagFilter('due:=2014-11-99') filtered_todos = otf.filter(todos) self.assertEqual(todolist_to_string(filtered_todos), "")
def test_filter28(self): todos = load_file('test/data/FilterTest3.txt') otf = Filter.OrdinalTagFilter('value:<16a') filtered_todos = otf.filter(todos) self.assertEqual(todolist_to_string(filtered_todos), "")
def test_filter10(self): """ Test instance filter """ todos = load_file('test/data/FilterTest1.txt') instance_filter = Filter.InstanceFilter([]) filtered_todos = instance_filter.filter(todos) self.assertEqual([], filtered_todos)
def test_filter14(self): """ Test limit filter. """ todos = load_file('test/data/FilterTest1.txt') limit_filter = Filter.LimitFilter(-1) filtered_todos = limit_filter.filter(todos) self.assertEqual(todos, filtered_todos)
def test_filter15(self): """ Test limit filter. """ todos = load_file('test/data/FilterTest1.txt') limit_filter = Filter.LimitFilter(100) filtered_todos = limit_filter.filter(todos) self.assertEqual(len(filtered_todos), 4)
def test_sort14(self): sorter = Sorter('desc:importance-average') todolist = load_file_to_todolist('test/data/SorterTest10.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest10-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_filter13(self): """ Test limit filter. """ todos = load_file('test/data/FilterTest1.txt') limit_filter = Filter.LimitFilter(1) filtered_todos = limit_filter.filter(todos) self.assertEquals(len(filtered_todos), 1) self.assertEquals(filtered_todos[0].source(), '(C) This is part of some +Project')
def test_filter13(self): """ Test limit filter. """ todos = load_file('test/data/FilterTest1.txt') limit_filter = Filter.LimitFilter(1) filtered_todos = limit_filter.filter(todos) self.assertEqual(len(filtered_todos), 1) self.assertEqual(filtered_todos[0].source(), '(C) This is part of some +Project')
def test_filter7(self): """ Tests the dependency filter. """ todolist = load_file_to_todolist('test/data/FilterTest2.txt') depfilter = Filter.DependencyFilter(todolist) filtered_todos = depfilter.filter(todolist.todos()) reference = load_file('test/data/FilterTest2-result.txt') self.assertEquals(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_filter7(self): """ Tests the dependency filter. """ todolist = load_file_to_todolist('test/data/FilterTest2.txt') depfilter = Filter.DependencyFilter(todolist) filtered_todos = depfilter.filter(todolist.todos()) reference = load_file('test/data/FilterTest2-result.txt') self.assertEqual(todolist_to_string(filtered_todos), \ todolist_to_string(reference))
def test_sort16(self): """ Check sort of low priority tasks (D or lower) with non-priority tasks. """ sorter = Sorter('desc:importance,desc:prio') todolist = load_file_to_todolist('test/data/SorterTest12.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest12-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_view(self): """ Check filters and printer for views. """ todofile = TodoFile('test/data/FilterTest1.txt') ref = load_file('test/data/ViewTest1-result.txt') todolist = TodoList(todofile.read()) sorter = Sorter('text') todofilter = Filter.GrepFilter('+Project') view = todolist.view(sorter, [todofilter]) self.assertEquals(str(view), todolist_to_string(ref))
def test_view(self): """ Check filters and printer for views. """ todofile = TodoFile("test/data/FilterTest1.txt") ref = load_file("test/data/ViewTest1-result.txt") todolist = TodoList(todofile.read()) sorter = Sorter("text") todofilter = Filter.GrepFilter("+Project") view = todolist.view(sorter, [todofilter]) self.assertEqual(print_view(view), todolist_to_string(ref))
def test_sort15(self): """ Test that own importance is used when average turns out to be lower. """ sorter = Sorter('desc:importance-average') todolist = load_file_to_todolist('test/data/SorterTest11.txt') view = todolist.view(sorter, []) result = load_file('test/data/SorterTest11-result.txt') self.assertEqual(print_view(view), todolist_to_string(result))
def test_empty_file(self): todofile = load_file('test/data/TodoFileTest1.txt') self.assertEqual(len(todofile), 0)
def test_empty_file(self): todofile = load_file('test/data/TodoFileTest1.txt') self.assertEquals(len(todofile), 0)
def test_utf_8(self): todofile = load_file('test/data/utf-8.txt') self.assertEqual(todofile[0].source(), u('(C) \u25ba UTF-8 test \u25c4'))
def test_filter19(self): todos = load_file('test/data/FilterTest1.txt') grep = Filter.GrepFilter(1) filtered_todos = grep.filter(todos) self.assertEquals(filtered_todos, [])