def test_format_with_tags(self):
     # for projects, ending colon can be either before or after tags
     # so allow for either by reconverting
     line = 'project 1 @tag1:\n\t- task 1 @tag2\n\tcomment 1 @tag3'
     til_1 = TaskPaper.parse(line.splitlines())
     output_1 = til_1.format()
     til_2 = TaskPaper.parse(output_1.splitlines())
     output_2 = til_2.format()
     self.assertEqual(output_1, output_2)
 def test_format_with_tags(self):
     # for projects, ending colon can be either before or after tags
     # so allow for either by reconverting
     line = 'project 1 @tag1:\n\t- task 1 @tag2\n\tcomment 1 @tag3'
     til_1 = TaskPaper.parse(line.splitlines())
     output_1 = til_1.format()
     til_2 = TaskPaper.parse(output_1.splitlines())
     output_2 = til_2.format()
     self.assertEqual(output_1, output_2)
 def test_empty_args(self):
     "proper parsing of empty tag arguments"
     til = TaskPaper.parse(self.lines)
     matches = list(til['tag4'])
     self.assertEqual(1, len(matches))
     self.assertEqual(matches[0].txt, '- task 4 empty args')
     self.assertIs(matches[0].tags['tag4'], None)
 def test_nested_escaped_tags(self):
     "proper parsing of escaped closing parens"
     til = TaskPaper.parse(self.lines)
     matches = list(til['tag3'])
     self.assertEqual(1, len(matches))
     self.assertEqual(matches[0].tags['tag3'],
                      'with \\) escaped @nested(tag\\)')
 def test_empty_args(self):
     "proper parsing of empty tag arguments"
     til = TaskPaper.parse(self.lines)
     matches = list(til['tag4'])
     self.assertEqual(1, len(matches))
     self.assertEqual(matches[0].txt, '- task 4 empty args')
     self.assertIs(matches[0].tags['tag4'], None)
 def test_list_of_strings(self):
     lines = 'project 1:\n\t- task 1\n\t- task 2\n'.splitlines()
     til = TaskPaper.parse(lines)
     # one top level item
     self.assertEqual(1, len(til.items))
     # 3 total items
     self.assertEqual(3, sum(1 for _ in til))
 def test_list_of_strings(self):
     lines = 'project 1:\n\t- task 1\n\t- task 2\n'.splitlines()
     til = TaskPaper.parse(lines)
     # one top level item
     self.assertEqual(1, len(til.items))
     # 3 total items
     self.assertEqual(3, sum(1 for _ in til))
 def test_find_desired_tags(self):
     "find just specified tags"
     til = TaskPaper.parse(self.lines)
     for tag in ('tag1', 'tag2'):
         tag_count = sum(1 for _ in til.select(lambda _: tag in _.tags))
         self.assertEqual(2, tag_count)
 def test_find_all_tags(self):
     "Find all tags"
     til = TaskPaper.parse(self.lines)
     tag_count = sum(len(i.tags.keys()) for i in til)
     self.assertEqual(6, tag_count)
Esempio n. 10
0
 def test_one_level(self):
     "Can't parse string, but doesn't error"
     input_string = 'project 1:\n\t- task 1\n\t- task 2\n'
     til = TaskPaper.parse(input_string)
     # will claim some large number of items
     self.assertTrue(len(til.items) > 3)
Esempio n. 11
0
 def test_empty_taskpaper(self):
     "should handle empty object okay"
     til = TaskPaper()
     self.assertEqual(0, len(til.items))
     self.assertEqual(0, til.level())
Esempio n. 12
0
 def test_empty_input(self):
     "should handle empty file okay"
     til = TaskPaper.parse('')
     self.assertEqual(0, len(til.items))
Esempio n. 13
0
 def test_empty_input(self):
     "should handle empty file okay"
     til = TaskPaper.parse('')
     self.assertEqual(0, len(til.items))
Esempio n. 14
0
 def test_format_no_tags(self):
     line = 'project 1:\n\t- task 1\n\tcomment 1'
     til = TaskPaper.parse(line.splitlines())
     output = til.format()
     self.assertEqual(line, output)
Esempio n. 15
0
 def test_format_no_tags(self):
     line = 'project 1:\n\t- task 1\n\tcomment 1'
     til = TaskPaper.parse(line.splitlines())
     output = til.format()
     self.assertEqual(line, output)
Esempio n. 16
0
 def test_nested_escaped_tags(self):
     "proper parsing of escaped closing parens"
     til = TaskPaper.parse(self.lines)
     matches = list(til['tag3'])
     self.assertEqual(1, len(matches))
     self.assertEqual(matches[0].tags['tag3'], 'with \\) escaped @nested(tag\\)')
Esempio n. 17
0
 def test_find_desired_tags(self):
     "find just specified tags"
     til = TaskPaper.parse(self.lines)
     for tag in ('tag1', 'tag2'):
         tag_count = sum(1 for _ in til.select(lambda _: tag in _.tags))
         self.assertEqual(2, tag_count)
Esempio n. 18
0
 def test_find_all_tags(self):
     "Find all tags"
     til = TaskPaper.parse(self.lines)
     tag_count = sum(len(i.tags.keys()) for i in til)
     self.assertEqual(6, tag_count)
Esempio n. 19
0
 def test_one_level(self):
     "Can't parse string, but doesn't error"
     input_string = 'project 1:\n\t- task 1\n\t- task 2\n'
     til = TaskPaper.parse(input_string)
     # will claim some large number of items
     self.assertTrue(len(til.items) > 3)
Esempio n. 20
0
 def test_empty_taskpaper(self):
     "should handle empty object okay"
     til = TaskPaper()
     self.assertEqual(0, len(til.items))
     self.assertEqual(0, til.level())