Beispiel #1
0
    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.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #2
0
    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))
Beispiel #3
0
    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.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #4
0
    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))
Beispiel #5
0
    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.assertEquals(todolist_to_string(filtered_todos),
            todolist_to_string(reference))
Beispiel #6
0
    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))
Beispiel #7
0
    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))
Beispiel #8
0
    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))
Beispiel #9
0
    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))
Beispiel #10
0
    def test_filter4(self):
        """ Test case insensitive match. """
        todos = load_file('test/data/FilterTest1.txt')
        grep = Filter.GrepFilter('+project')

        filtered_todos = grep.filter(todos)
        reference = load_file('test/data/FilterTest1a-result.txt')

        self.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #11
0
    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.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #12
0
    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))
Beispiel #13
0
    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))
Beispiel #14
0
    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.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #15
0
    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.assertEquals(todolist_to_string(filtered_todos), \
            todolist_to_string(reference))
Beispiel #16
0
    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))
Beispiel #17
0
    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)
Beispiel #18
0
    def test_filter28(self):
        todos = load_file('test/data/FilterTest3.txt')
        otf = Filter.OrdinalTagFilter('value:<16a')

        filtered_todos = otf.filter(todos)

        self.assertEquals(todolist_to_string(filtered_todos), "")
Beispiel #19
0
    def test_filter23(self):
        todos = load_file('test/data/FilterTest3.txt')
        otf = Filter.OrdinalTagFilter('due:=2014-11-99')

        filtered_todos = otf.filter(todos)

        self.assertEquals(todolist_to_string(filtered_todos), "")
Beispiel #20
0
    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), "")
Beispiel #21
0
    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), "")
Beispiel #22
0
    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))
Beispiel #23
0
    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))
Beispiel #24
0
    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))
Beispiel #25
0
    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))
Beispiel #26
0
    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))