示例#1
0
文件: tasklist.py 项目: thorhans/zimt
    def testLabelledCheckboxes(self):
        mydate = '%04i-%02i-%02i' % parse_date('11/12')

        wanted = [
            (t('TODO: test heading with label'), []),
            (t('A'), []),
            (t('B'), []),
            (t('C'), []),
            (t('FIXME: dus'), []),

            # this time does not inherit due-date from non-task:
            (t('TODO: BAR !!!', prio=3), []),
            (t('Some more tasks !!!', prio=3, tags='home'), [
                (t('Foo !', prio=1, tags='home'), []),
                (t('Bar', prio=3, tags='home'), []),
            ]),
            (t('TODO: dus'), []),
            (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []),
            (t('TODO: dus - list item'), []),
            (t('FIXME: jaja - TODO !! @FIXME - list item',
               prio=2,
               tags='FIXME'), []),
            (t('A', tags='someday'), []),
            (t('B', tags='someday'), [
                (t('B-1', tags='someday'), []),
            ]),
            (t('C', tags='someday'), []),
            (t('main task', tags='home'), [
                (t('do this', open=False, tags='home'), []),
                (t('Next: do that', tags='home'), []),
                (t('Next: do something else', tags='home'), []),
            ]),
        ]

        tree = WikiParser().parse(WIKI_TEXT)
        tb = TokenBuilder()
        tree.visit(tb)
        tokens = tb.tokens
        testTokenStream(tokens)

        parser = TaskParser(all_checkboxes=False)
        with tests.LoggingFilter('zim.plugins.tasklist',
                                 'Invalid date format'):
            tasks = parser.parse(tokens)

        #~ import pprint; pprint.pprint(tasks)
        self.assertEqual(tasks, wanted)
示例#2
0
文件: tasklist.py 项目: thorhans/zimt
    def testDate(self):
        text = '''\
[ ] Task <2018-12
[ ] Task >2018-12
'''
        wanted = [(t('Task <2018-12', due='2018-12-31'), []),
                  (t('Task >2018-12', start='2018-12-01'), [])]

        tree = WikiParser().parse(text)
        tb = TokenBuilder()
        tree.visit(tb)
        tokens = tb.tokens
        testTokenStream(tokens)

        parser = TaskParser()
        tasks = parser.parse(tokens)

        #import pprint; pprint.pprint(tasks)
        self.assertEqual(tasks, wanted)
示例#3
0
    def testLabelledCheckboxes(self):
        from zim.plugins.tasklist.indexer import TaskParser

        from zim.parsing import parse_date
        NO_DATE = '9999'

        def t(desc, open=True, start=0, due=NO_DATE, prio=0, tags=''):
            # Generate a task tuple
            # 0:open, 1:prio, 2:start, 3:due, 4:tags, 5:desc
            if tags:
                tags = set(str(tags).split(','))
            else:
                tags = set()
            return [open, prio, start, due, tags, str(desc)]

        mydate = '%04i-%02i-%02i' % parse_date('11/12')

        wanted = [
            (t('TODO: test heading with label'), []),
            (t('A'), []),
            (t('B'), []),
            (t('C'), []),
            (t('FIXME: dus'), []),

            # this time does not inherit due-date from non-task:
            (t('TODO: BAR !!!', prio=3), []),
            (t('Some more tasks !!!', prio=3, tags='home'), [
                (t('Foo !', prio=1, tags='home'), []),
                (t('Bar', prio=3, tags='home'), []),
            ]),
            (t('TODO: dus'), []),
            (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []),
            (t('TODO: dus - list item'), []),
            (t('FIXME: jaja - TODO !! @FIXME - list item',
               prio=2,
               tags='FIXME'), []),
            (t('A', tags='someday'), []),
            (t('B', tags='someday'), [
                (t('B-1', tags='someday'), []),
            ]),
            (t('C', tags='someday'), []),
            (t('main task', tags='home'), [
                (t('do this', open=False, tags='home'), []),
                (t('Next: do that', tags='home'), []),
                (t('Next: do something else', tags='home'), []),
            ]),
        ]

        tree = WikiParser().parse(WIKI_TEXT)
        tb = TokenBuilder()
        tree.visit(tb)
        tokens = tb.tokens
        testTokenStream(tokens)

        parser = TaskParser(all_checkboxes=False)
        with tests.LoggingFilter('zim.plugins.tasklist',
                                 'Invalid date format'):
            tasks = parser.parse(tokens)

        #~ import pprint; pprint.pprint(tasks)
        self.assertEqual(tasks, wanted)
示例#4
0
    def testAllCheckboxes(self):
        from zim.plugins.tasklist.indexer import TaskParser

        from zim.parsing import parse_date
        NO_DATE = '9999'

        def t(desc, open=True, start=0, due=NO_DATE, prio=0, tags=''):
            # Generate a task tuple
            # 0:open, 1:prio, 2:start, 3:due, 4:tags, 5:desc
            if tags:
                tags = set(str(tags).split(','))
            else:
                tags = set()
            return [open, prio, start, due, tags, str(desc)]

        mydate = '%04i-%02i-%02i' % parse_date('11/12')

        wanted = [
            (t('TODO: test heading with label'), []),
            (t('A'), []),
            (t('B'), []),
            (t('C'), []),
            (t('D'), []),
            (t('E'), []),
            (t('FIXME: dus'), []),
            (t('Simple'), []),
            (t('List'), []),
            (t('List with'), [
                (t('Nested items'), []),
                (t('Some are done', open=False), []),
                (t('Done but with open child', open=True), [
                    (t('Others not', open=False), []),
                    (t('FOOOOO'), []),
                ]),
            ]),
            (t('Bar'), []),
            (t('And then there are @tags', tags='tags'), []),
            (t('Next: And due dates'), []),
            (t('Date [d: 11/12]', due=mydate), []),
            (
                t('Date [d: 11/12/2012]', due='2012-12-11'),
                [
                    (t('TODO: BAR !!!', prio=3, due='2012-12-11'), []),
                    # due date is inherited
                ]),
            (t('Date <2012-03-27 >2012-03-01',
               due='2012-03-27',
               start='2012-03-01'), []),
            (t('Date < wk1213.3', due='2012-03-28'), []),
            (t('Date < wk1213.3! with punctuation', due='2012-03-28',
               prio=1), []),
            (t('Not a date < wk1213.8'), []),
            (t('Not a date < wk1213foooooo'), []),

            # this list inherits the @home tag - and inherits prio
            (t('Some more tasks !!!', prio=3, tags='home'), [
                (t('Foo !', prio=1, tags='home'), []),
                (t('Bar', prio=3, tags='home'), []),
            ]),
            (t('TODO: dus'), []),
            (t('FIXME: jaja - TODO !! @FIXME', prio=2, tags='FIXME'), []),
            (t('TODO: dus - list item'), []),
            (t('FIXME: jaja - TODO !! @FIXME - list item',
               prio=2,
               tags='FIXME'), []),
            (t('Sub item bullets'), []),
            (t('Sub item numbered'), []),
            (t('Main @tag1 @tag2 !', prio=1, tags='tag1,tag2'), [
                (t('Sub1', prio=1, open=False, tags='tag1,tag2'), []),
                (t('Sub2 @tag3 !!!!', prio=4, tags='tag1,tag2,tag3'), [
                    (t('Sub2-1', prio=4, open=False,
                       tags='tag1,tag2,tag3'), []),
                    (t('Sub2-2 @tag4',
                       prio=4,
                       open=False,
                       tags='tag1,tag2,tag3,tag4'), []),
                    (t('Sub2-3', prio=4, tags='tag1,tag2,tag3'), []),
                ]),
                (t('Sub3', prio=1, tags='tag1,tag2'), []),
            ]),
            (t('A', tags='someday'), []),
            (t('B', tags='someday'), [
                (t('B-1', tags='someday'), []),
            ]),
            (t('C', tags='someday'), []),
            (t('main task', tags='home'), [
                (t('do this', open=False, tags='home'), []),
                (t('Next: do that', tags='home'), []),
                (t('Next: do something else', tags='home'), []),
            ]),
            (t('Closed parent task', open=True), [
                (t('With open child'), []),
                (t('Must be open as well to show up in list'), []),
            ]),
            (t('Closed parent task', open=False), [
                (t('With closed children', open=False), []),
                (t('Should not', open=False), []),
            ]),
        ]

        tree = WikiParser().parse(WIKI_TEXT)
        tb = TokenBuilder()
        tree.visit(tb)
        tokens = tb.tokens
        testTokenStream(tokens)

        parser = TaskParser()
        with tests.LoggingFilter('zim.plugins.tasklist',
                                 'Invalid date format'):
            tasks = parser.parse(tokens)

        #~ import pprint; pprint.pprint(tasks)
        self.assertEqual(tasks, wanted)