Skip to content

Commit 9727d8c

Browse files
adapt heading parse tests
We do test heading parsing and not date-time parsing, so these cases should be enough. Sorting should ignore inactive dates -> test added.
1 parent 011fbff commit 9727d8c

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/test_libheading.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ def setUp(self):
3030
self.h_no_date = Heading.parse_heading_from_data(tmp,
3131
self.allowed_todo_states)
3232

33+
tmp = ["* This heading has an incative date [2011-08-26 Fri]"]
34+
self.h_no_date_2 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states)
35+
36+
3337
def test_heading_parsing_no_date(self):
3438
"""""
3539
'text' doesn't contain any valid date.
@@ -38,15 +42,7 @@ def test_heading_parsing_no_date(self):
3842
h = Heading.parse_heading_from_data(text, self.allowed_todo_states)
3943
self.assertEqual(None, h.active_date)
4044

41-
text = ["* TODO This is a test <2011-08-25>"]
42-
h = Heading.parse_heading_from_data(text, self.allowed_todo_states)
43-
self.assertEqual(None, h.active_date)
44-
45-
text = ["* TODO This is a test <2011-08-25 Wednesday>"]
46-
h = Heading.parse_heading_from_data(text, self.allowed_todo_states)
47-
self.assertEqual(None, h.active_date)
48-
49-
text = ["* TODO This is a test <20110825>"]
45+
text = ["* TODO This is a test"]
5046
h = Heading.parse_heading_from_data(text, self.allowed_todo_states)
5147
self.assertEqual(None, h.active_date)
5248

@@ -66,6 +62,7 @@ def test_heading_parsing_with_date(self):
6662
h = Heading.parse_heading_from_data(text, self.allowed_todo_states)
6763
self.assertEqual(odate, h.active_date)
6864

65+
6966
def test_heading_parsing_with_date_and_body(self):
7067
"""""
7168
'text' contains valid dates (in the body).
@@ -148,6 +145,11 @@ def test_sorting_of_headings(self):
148145
[self.h1, self.h2_datetime, self.h2, self.h3, self.h_no_date],
149146
sorted([self.h2_datetime, self.h3, self.h2, self.h_no_date, self.h1]))
150147

148+
self.assertEqual(
149+
[self.h1, self.h2_datetime, self.h2, self.h3,
150+
self.h_no_date_2],
151+
sorted([self.h2_datetime, self.h3, self.h2,
152+
self.h_no_date_2, self.h1]))
151153

152154
def suite():
153155
return unittest.TestLoader().loadTestsFromTestCase(

0 commit comments

Comments
 (0)