def test_heading_parsing_with_date_and_body(self): """"" 'text' contains valid dates (in the body). """ # orgdatetime text = ["* TODO This is a test <2011-08-25 Thu 10:10> :hallo:", "some body text", "some body text"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertTrue(isinstance(h.active_date, OrgDateTime)) self.assertEqual("<2011-08-25 Thu 10:10>", str(h.active_date)) text = ["* TODO This is a test :hallo:", "some body text", "some body text<2011-08-25 Thu 10:10>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertTrue(isinstance(h.active_date, OrgDateTime)) self.assertEqual("<2011-08-25 Thu 10:10>", str(h.active_date)) text = ["* TODO This is a test :hallo:", "some body text <2011-08-24 Wed>", "some body text<2011-08-25 Thu 10:10>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) odate = OrgDate(True, 2011, 8, 24) self.assertEqual(odate, h.active_date)
def test_heading_parsing_with_date_and_body(self): """"" 'text' contains valid dates (in the body). """ # orgdatetime text = [ "* TODO This is a test <2011-08-25 Thu 10:10> :hallo:", "some body text", "some body text" ] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertTrue(isinstance(h.active_date, OrgDateTime)) self.assertEqual("<2011-08-25 Thu 10:10>", str(h.active_date)) text = [ "* TODO This is a test :hallo:", "some body text", "some body text<2011-08-25 Thu 10:10>" ] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertTrue(isinstance(h.active_date, OrgDateTime)) self.assertEqual("<2011-08-25 Thu 10:10>", str(h.active_date)) text = [ "* TODO This is a test :hallo:", "some body text <2011-08-24 Wed>", "some body text<2011-08-25 Thu 10:10>" ] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) odate = OrgDate(True, 2011, 8, 24) self.assertEqual(odate, h.active_date)
def test_heading_parsing_with_date(self): """"" 'text' does contain valid dates. """ # orgdate text = ["* TODO This is a test <2011-08-24 Wed> :hallo:"] odate = OrgDate(True, 2011, 8, 24) h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(odate, h.active_date) # orgdatetime text = ["* TODO This is a test <2011-08-25 Thu 10:10> :hallo:"] odate = OrgDateTime(True, 2011, 8, 25, 10, 10) h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(odate, h.active_date)
def test_heading_parsing_with_date(self): """"" 'text' does contain valid dates. """ # orgdate text = ["* TODO This is a test <2011-08-24 Wed> :hallo:"] odate = OrgDate(True, 2011, 8, 24) h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(odate, h.active_date) # orgdatetime text = ["* TODO This is a test <2011-08-25 Thu 10:10> :hallo:"] odate = OrgDateTime(True, 2011, 8, 25, 10, 10) h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(odate, h.active_date)
def setUp(self): self.allowed_todo_states = ["TODO"] tmp = ["* This heading is earlier <2011-08-24 Wed>"] self.h1 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-25 Thu>"] self.h2 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-25 Thu 10:20>"] self.h2_datetime = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-26 Fri 10:20>"] self.h3 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading has no date and should be later than the rest"] self.h_no_date = Heading.parse_heading_from_data(tmp, self.allowed_todo_states)
def test_heading_parsing_no_date(self): """"" 'text' doesn't contain any valid date. """ text = ["* TODO This is a test :hallo:"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <2011-08-25>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <2011-08-25 Wednesday>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <20110825>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date)
def test_heading_parsing_no_date(self): """"" 'text' doesn't contain any valid date. """ text = ["* TODO This is a test :hallo:"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <2011-08-25>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <2011-08-25 Wednesday>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date) text = ["* TODO This is a test <20110825>"] h = Heading.parse_heading_from_data(text, self.allowed_todo_states) self.assertEqual(None, h.active_date)
def test_filter_items_with_some_todos_and_dates(self): u""" Only the headings with todo and dates should be retunrned. """ tmp = [u"* TODO OrgMode Demo und Tests" u"<2011-08-22 Mon>"] headings = [Heading.parse_heading_from_data(tmp, [u'TODO'])] filtered = list(filter_items(headings, [is_within_week_and_active_todo])) self.assertEqual(len(filtered), 1) self.assertEqual(headings, filtered) tmp = [Heading.parse_heading_from_data([u"** DONE something <2011-08-10 Wed>"], [u'TODO']), Heading.parse_heading_from_data([u"*** TODO rsitenaoritns more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data([u"*** DONE some more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data([u"*** TODO some more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data([u"** DONE something2 <2011-08-10 Wed>"], [u'TODO']) ] for h in tmp: headings.append(h) filtered = list(filter_items(headings, [is_within_week_and_active_todo])) self.assertEqual(len(filtered), 3) self.assertEqual(filtered, [headings[0], headings[2], headings[4]])
def test_filter_items_with_some_todos_and_dates(self): u""" Only the headings with todo and dates should be retunrned. """ tmp = [u"* TODO OrgMode Demo und Tests" u"<2011-08-22 Mon>"] headings = [Heading.parse_heading_from_data(tmp, [u'TODO'])] filtered = list( filter_items(headings, [is_within_week_and_active_todo])) self.assertEqual(len(filtered), 1) self.assertEqual(headings, filtered) tmp = [ Heading.parse_heading_from_data( [u"** DONE something <2011-08-10 Wed>"], [u'TODO']), Heading.parse_heading_from_data( [u"*** TODO rsitenaoritns more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data( [u"*** DONE some more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data( [u"*** TODO some more <2011-08-25 Thu>"], [u'TODO']), Heading.parse_heading_from_data( [u"** DONE something2 <2011-08-10 Wed>"], [u'TODO']) ] for h in tmp: headings.append(h) filtered = list( filter_items(headings, [is_within_week_and_active_todo])) self.assertEqual(len(filtered), 3) self.assertEqual(filtered, [headings[0], headings[2], headings[4]])
def setUp(self): self.allowed_todo_states = ["TODO"] tmp = ["* This heading is earlier <2011-08-24 Wed>"] self.h1 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-25 Thu>"] self.h2 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-25 Thu 10:20>"] self.h2_datetime = Heading.parse_heading_from_data( tmp, self.allowed_todo_states) tmp = ["* This heading is later <2011-08-26 Fri 10:20>"] self.h3 = Heading.parse_heading_from_data(tmp, self.allowed_todo_states) tmp = ["* This heading has no date and should be later than the rest"] self.h_no_date = Heading.parse_heading_from_data( tmp, self.allowed_todo_states)