def test_textline(self):
        self.parser = yacc.get_parser("textualelement")  # we are testing just part of the parser

        res = self.parse("a")
        self.assertEqual(repr(res), "TextLine('a',[])")
        res = self.parse("a b")
        self.assertEqual(repr(res), "TextLine('a b',[])")

        # test tags
        res = self.parse("#ttt")
        self.assertEqual(repr(res), "TextLine('#ttt',['#ttt'])")
        res = self.parse("a#ttt")
        self.assertEqual(repr(res), "TextLine('a#ttt',['#ttt'])")
        res = self.parse("a#ttt#bbb")
        self.assertEqual(repr(res), "TextLine('a#ttt#bbb',['#ttt', '#bbb'])")

        # test persons
        res = self.parse("@ppp")
        self.assertEqual(repr(res), "TextLine('@ppp',['@ppp'])")
        res = self.parse("a@ppp")
        self.assertEqual(repr(res), "TextLine('a@ppp',['@ppp'])")
        res = self.parse("a@ppp@ddd")
        self.assertEqual(repr(res), "TextLine('a@ppp@ddd',['@ppp', '@ddd'])")

        # test other issues
        res = self.parse("32")
        self.assertEqual(repr(res), "TextLine('32',[])")
        res = self.parse("a=b")
        self.assertEqual(repr(res), "TextLine('a=b',[])")
        res = self.parse("a-b")
        self.assertEqual(repr(res), "TextLine('a-b',[])")

        # test startwithspace
        res = self.parse(" a")
        self.assertEqual(repr(res), "TextLine(' a',[])")
 def test_task_error(self):
     self.parser = yacc.get_parser(
         'task')  # we are testing just part of the parser
     res = self.parse("-a \n")
     self.assertEqual(repr(res), "Task(TextLine('a ',[]),[])")
     res = self.parse("-a []\n")
     self.assertEqual(repr(res), "Task(TextLine('a ',[]),[])")
    def test_task(self):
        self.parser = yacc.get_parser("task")  # we are testing just part of the parser
        res = self.parse("-a [2]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4)])")
        res = self.parse("-a  [2]\n")
        self.assertEqual(repr(res), "Task(TextLine('a  ',[]),[LexToken(NUMBER,'2',1,5)])")
        res = self.parse("-a [2 a]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TEXT,'a',1,6)])")
        res = self.parse("-a [2  a]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TEXT,'a',1,7)])")
        res = self.parse("-a [a 2]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(TEXT,'a',1,4), LexToken(NUMBER,'2',1,6)])")
        res = self.parse("-a [2 #tag]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TAG,'#tag',1,6)])")
        res = self.parse("-a [2 @nick]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(PERSON,'@nick',1,6)])")

        # should this be right
        res = self.parse("-a [2 2]\n")
        self.assertEqual(repr(res), "None")

        res = self.parse("-a [aa]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(TEXT,'aa',1,4)])")

        # test for space beween [] and new line
        res = self.parse("-a [aa] \n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(TEXT,'aa',1,4)])")

        self.assertRaises(Exception, self.parse, "-a [aa =d]\n")

        # now test spaces left and right, inside brackets
        res = self.parse("-a [ #b ]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(TAG,'#b',1,5)])")
        res = self.parse("-a [  #b  ]\n")
        self.assertEqual(repr(res), "Task(TextLine('a ',[]),[LexToken(TAG,'#b',1,6)])")
    def test_task(self):
        self.parser = yacc.get_parser(
            'task')  # we are testing just part of the parser
        res = self.parse("-a [2]\n")
        self.assertEqual(repr(res),
                         "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4)])")
        res = self.parse("-a  [2]\n")
        self.assertEqual(
            repr(res), "Task(TextLine('a  ',[]),[LexToken(NUMBER,'2',1,5)])")
        res = self.parse("-a [2 a]\n")
        self.assertEqual(
            repr(res),
            "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TEXT,'a',1,6)])"
        )
        res = self.parse("-a [2  a]\n")
        self.assertEqual(
            repr(res),
            "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TEXT,'a',1,7)])"
        )
        res = self.parse("-a [a 2]\n")
        self.assertEqual(
            repr(res),
            "Task(TextLine('a ',[]),[LexToken(TEXT,'a',1,4), LexToken(NUMBER,'2',1,6)])"
        )
        res = self.parse("-a [2 #tag]\n")
        self.assertEqual(
            repr(res),
            "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(TAG,'#tag',1,6)])"
        )
        res = self.parse("-a [2 @nick]\n")
        self.assertEqual(
            repr(res),
            "Task(TextLine('a ',[]),[LexToken(NUMBER,'2',1,4), LexToken(PERSON,'@nick',1,6)])"
        )

        # should this be right
        res = self.parse("-a [2 2]\n")
        self.assertEqual(repr(res), "None")

        res = self.parse("-a [aa]\n")
        self.assertEqual(repr(res),
                         "Task(TextLine('a ',[]),[LexToken(TEXT,'aa',1,4)])")

        # test for space beween [] and new line
        res = self.parse("-a [aa] \n")
        self.assertEqual(repr(res),
                         "Task(TextLine('a ',[]),[LexToken(TEXT,'aa',1,4)])")

        self.assertRaises(Exception, self.parse, "-a [aa =d]\n")

        # now test spaces left and right, inside brackets
        res = self.parse("-a [ #b ]\n")
        self.assertEqual(repr(res),
                         "Task(TextLine('a ',[]),[LexToken(TAG,'#b',1,5)])")
        res = self.parse("-a [  #b  ]\n")
        self.assertEqual(repr(res),
                         "Task(TextLine('a ',[]),[LexToken(TAG,'#b',1,6)])")
    def test_storybody(self):
        self.parser = yacc.get_parser("storybody")  # we are testing just part of the parser
        res = self.parse("description\n")
        self.assertEqual(repr(res), "TextLine('description',[])")

        # make sure new lines are allowed at the end
        self.parser = yacc.get_parser("storybody")
        res = self.parse("description\n\n")
        self.assertEqual(repr(res), "TextLine('description\\n',[])")

        # make sure lots of new lines are allowed at the end
        self.parser = yacc.get_parser("storybody")
        res = self.parse("description\n\n\n\n")
        self.assertEqual(repr(res), "TextLine('description\\n\\n\\n',[])")

        # let's try to end with a tab - this is harder to swallow
        self.parser = yacc.get_parser("storybody")
        res = self.parse("description\n \n\t\n")
        self.assertEqual(repr(res), "TextLine('description\\n \\n\\t',[])")
 def test_storytitle(self):
     self.parser = yacc.get_parser("storytitle")  # we are testing just part of the parser
     res = self.parse("=a\n")
     self.assertEqual(repr(res), "TextLine('a',[])")
     # test spacing
     res = self.parse("= a\n")
     self.assertEqual(repr(res), "TextLine(' a',[])")
     res = self.parse("=  a\n")
     self.assertEqual(repr(res), "TextLine('  a',[])")
     res = self.parse("=  a \n")
    def test_storybody(self):
        self.parser = yacc.get_parser(
            'storybody')  # we are testing just part of the parser
        res = self.parse("description\n")
        self.assertEqual(repr(res), "TextLine('description',[])")

        # make sure new lines are allowed at the end
        self.parser = yacc.get_parser('storybody')
        res = self.parse("description\n\n")
        self.assertEqual(repr(res), "TextLine('description\\n',[])")

        # make sure lots of new lines are allowed at the end
        self.parser = yacc.get_parser('storybody')
        res = self.parse("description\n\n\n\n")
        self.assertEqual(repr(res), "TextLine('description\\n\\n\\n',[])")

        # let's try to end with a tab - this is harder to swallow
        self.parser = yacc.get_parser('storybody')
        res = self.parse("description\n \n\t\n")
        self.assertEqual(repr(res), "TextLine('description\\n \\n\\t',[])")
 def test_storytitle(self):
     self.parser = yacc.get_parser(
         'storytitle')  # we are testing just part of the parser
     res = self.parse("=a\n")
     self.assertEqual(repr(res), "TextLine('a',[])")
     # test spacing
     res = self.parse("= a\n")
     self.assertEqual(repr(res), "TextLine(' a',[])")
     res = self.parse("=  a\n")
     self.assertEqual(repr(res), "TextLine('  a',[])")
     res = self.parse("=  a \n")
 def test_story_with_tasks(self):
     self.parser = yacc.get_parser("story")  # we are testing just part of the parser
     res = self.parse("=st\ndescription\n-t1 [1]\n")
     self.assertEqual(
         repr(res), "Story('st','description',[Task(TextLine('t1 ',[]),[LexToken(NUMBER,'1',1,21)])],[])"
     )
     res = self.parse("=st\ndescription\n-t1 [1 #tag1]\n")
     self.assertEqual(
         repr(res),
         "Story('st','description',[Task(TextLine('t1 ',[]),[LexToken(NUMBER,'1',1,21), LexToken(TAG,'#tag1',1,23)])],[])",
     )
 def test_story_with_tasks(self):
     self.parser = yacc.get_parser(
         'story')  # we are testing just part of the parser
     res = self.parse("=st\ndescription\n-t1 [1]\n")
     self.assertEqual(
         repr(res),
         "Story('st','description',[Task(TextLine('t1 ',[]),[LexToken(NUMBER,'1',1,21)])],[])"
     )
     res = self.parse("=st\ndescription\n-t1 [1 #tag1]\n")
     self.assertEqual(
         repr(res),
         "Story('st','description',[Task(TextLine('t1 ',[]),[LexToken(NUMBER,'1',1,21), LexToken(TAG,'#tag1',1,23)])],[])"
     )
Exemple #11
0
    def test_story(self):
        self.parser = yacc.get_parser("story")  # we are testing just part of the parser
        res = self.parse("=st\ndescription\n")
        self.assertEqual(repr(res), "Story('st','description',[],[])")

        res = self.parse("=st#tag\ndescript#tag2 ion\n")
        self.assertEqual(repr(res), "Story('st#tag','descript#tag2 ion',[],['#tag', '#tag2'])")

        self.parser = yacc.get_parser("story")  # we are testing just part of the parser
        res = self.parse("=st\ndescription line1\ndescription line 2\n")
        self.assertEqual(repr(res), "Story('st','description line1\\ndescription line 2',[],[])")
        self.parser = yacc.get_parser("story")  # we are testing just part of the parser
        res = self.parse("=st\ndescription line1\n description line 2\n")
        self.assertEqual(repr(res), "Story('st','description line1\\n description line 2',[],[])")

        # test for tasks, buit no description
        res = self.parse("=st\n-a [1]\n")
        self.assertEqual(repr(res), "Story('st','',[Task(TextLine('a ',[]),[LexToken(NUMBER,'1',1,8)])],[])")

        # no description, but tags
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must]\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must]\n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must] \n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n [#fire #must] \n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n\n [#fire #must]\n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n\n [#fire #must] \n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n \n [#fire #must] \n\n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
        res = self.parse("=Fix zemanta.com/demo\n \n [#fire #must] \n \n-a\n")
        self.assertEqual(repr(res), "Story('Fix zemanta.com/demo',' ',[Task(TextLine('a',[]),[])],['#fire', '#must'])")
    def test_textline(self):
        self.parser = yacc.get_parser(
            'textualelement')  # we are testing just part of the parser

        res = self.parse("a")
        self.assertEqual(repr(res), "TextLine('a',[])")
        res = self.parse("a b")
        self.assertEqual(repr(res), "TextLine('a b',[])")

        # test tags
        res = self.parse("#ttt")
        self.assertEqual(repr(res), "TextLine('#ttt',['#ttt'])")
        res = self.parse("a#ttt")
        self.assertEqual(repr(res), "TextLine('a#ttt',['#ttt'])")
        res = self.parse("a#ttt#bbb")
        self.assertEqual(repr(res), "TextLine('a#ttt#bbb',['#ttt', '#bbb'])")

        # test persons
        res = self.parse("@ppp")
        self.assertEqual(repr(res), "TextLine('@ppp',['@ppp'])")
        res = self.parse("a@ppp")
        self.assertEqual(repr(res), "TextLine('a@ppp',['@ppp'])")
        res = self.parse("a@ppp@ddd")
        self.assertEqual(repr(res), "TextLine('a@ppp@ddd',['@ppp', '@ddd'])")

        # test other issues
        res = self.parse("32")
        self.assertEqual(repr(res), "TextLine('32',[])")
        res = self.parse("a=b")
        self.assertEqual(repr(res), "TextLine('a=b',[])")
        res = self.parse("a-b")
        self.assertEqual(repr(res), "TextLine('a-b',[])")

        # test startwithspace
        res = self.parse(" a")
        self.assertEqual(repr(res), "TextLine(' a',[])")
 def test_taskmeta(self):
     self.parser = yacc.get_parser(
         'taskmeta')  # we are testing just part of the parser
     res = self.parse("[2]")
     self.assertEqual(repr(res), "[LexToken(NUMBER,'2',1,1)]")
    def test_story(self):
        self.parser = yacc.get_parser(
            'story')  # we are testing just part of the parser
        res = self.parse("=st\ndescription\n")
        self.assertEqual(repr(res), "Story('st','description',[],[])")

        res = self.parse("=st#tag\ndescript#tag2 ion\n")
        self.assertEqual(
            repr(res),
            "Story('st#tag','descript#tag2 ion',[],['#tag', '#tag2'])")

        self.parser = yacc.get_parser(
            'story')  # we are testing just part of the parser
        res = self.parse("=st\ndescription line1\ndescription line 2\n")
        self.assertEqual(
            repr(res),
            "Story('st','description line1\\ndescription line 2',[],[])")
        self.parser = yacc.get_parser(
            'story')  # we are testing just part of the parser
        res = self.parse("=st\ndescription line1\n description line 2\n")
        self.assertEqual(
            repr(res),
            "Story('st','description line1\\n description line 2',[],[])")

        # test for tasks, buit no description
        res = self.parse("=st\n-a [1]\n")
        self.assertEqual(
            repr(res),
            "Story('st','',[Task(TextLine('a ',[]),[LexToken(NUMBER,'1',1,8)])],[])"
        )

        # no description, but tags
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must]\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must]\n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n[#fire #must] \n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n [#fire #must] \n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n\n [#fire #must]\n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n\n [#fire #must] \n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n \n [#fire #must] \n\n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo','',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
        res = self.parse("=Fix zemanta.com/demo\n \n [#fire #must] \n \n-a\n")
        self.assertEqual(
            repr(res),
            "Story('Fix zemanta.com/demo',' ',[Task(TextLine('a',[]),[])],['#fire', '#must'])"
        )
Exemple #15
0
 def test_task_error(self):
     self.parser = yacc.get_parser("task")  # we are testing just part of the parser
     res = self.parse("-a \n")
     self.assertEqual(repr(res), "Task(TextLine('a ',[]),[])")
     res = self.parse("-a []\n")
     self.assertEqual(repr(res), "Task(TextLine('a ',[]),[])")
Exemple #16
0
 def test_taskmeta(self):
     self.parser = yacc.get_parser("taskmeta")  # we are testing just part of the parser
     res = self.parse("[2]")
     self.assertEqual(repr(res), "[LexToken(NUMBER,'2',1,1)]")