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]])
示例#2
0
	def test_filter_items(self):
		# only headings with date and todo should be returned
		tmpdate = date.today()
		odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
		tmp_head = Heading(title=u'Refactor the code', todo=u'TODO', active_date=odate)
		headings = [tmp_head]
		filtered = filter_items(headings,
				[contains_active_date, contains_active_todo])

		self.assertEqual(len(filtered), 1)
		self.assertEqual(filtered, headings)

		# try a longer list
		headings = headings * 3
		filtered = filter_items(headings,
				[contains_active_date, contains_active_todo])

		self.assertEqual(len(filtered), 3)
		self.assertEqual(filtered, headings)

		# date does not contain all needed fields thus gets ignored
		tmpdate = date.today()
		odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
		tmp_head = Heading(title=u'Refactor the code', active_date=odate)
		headings = [tmp_head]
		filtered = filter_items(headings, [contains_active_date,
				contains_active_todo])
		self.assertEqual([], filtered)
	def test_filter_items(self):
		# only headings with date and todo should be returned
		vim.command(u_encode(u"let g:org_todo_keywords = ['TODO', 'STARTED', '|', 'DONE']"))
		tmpdate = date.today()
		odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
		tmp_head = Heading(title=u'Refactor the code', todo=u'TODO', active_date=odate)
		tmp_head_01 = Heading(title=u'Refactor the code', todo=u'STARTED', active_date=odate)
		headings = [tmp_head, tmp_head_01]
		filtered = list(filter_items(headings,
				[contains_active_date, contains_active_todo]))

		self.assertEqual(len(filtered), 2)
		self.assertEqual(filtered, headings)

		# try a longer list
		headings = headings * 3
		filtered = list(filter_items(headings,
				[contains_active_date, contains_active_todo]))

		self.assertEqual(len(filtered), 6)
		self.assertEqual(filtered, headings)

		# date does not contain all needed fields thus gets ignored
		tmpdate = date.today()
		odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
		tmp_head = Heading(title=u'Refactor the code', active_date=odate)
		headings = [tmp_head]
		filtered = list(filter_items(headings, [contains_active_date,
				contains_active_todo]))
		self.assertEqual([], filtered)
    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]])
示例#5
0
 def get_next_actions(self, documents):
     filtered = []
     for i, document in enumerate(documents):
         # filter and return headings
         tmp = filter_items(document.all_headings(),
                            [contains_next_action, is_leaf])
         filtered.extend(tmp)
     return filtered
示例#6
0
    def get_todo(self, documents):
        u"""
		Get the todo agenda for the given documents (list of document).
		"""
        filtered = []
        for document in iter(documents):
            # filter and return headings
            filtered.extend(
                filter_items(document.all_headings(), [contains_active_todo]))
        return sorted(filtered)
示例#7
0
 def get_stuck_projects(self, documents):
     filtered = []
     for i, document in enumerate(documents):
         # filter and return headings
         tmp = filter_items(document.all_headings(), [
             contains_active_todo, is_stuck, is_leaf,
             is_not_waiting_on_sibling
         ])
         filtered.extend(tmp)
     return sorted(filtered)
示例#8
0
	def get_todo(self, documents):
		u"""
		Get the todo agenda for the given documents (list of document).
		"""
		filtered = []
		for document in iter(documents):
			# filter and return headings
			filtered.extend(filter_items(document.all_headings(),
								[contains_active_todo]))
		return sorted(filtered)
示例#9
0
    def get_timestamped_items(self, documents):
        u"""
		Get all time-stamped items in a time-sorted way for the given
		documents (list of document).
		"""
        filtered = []
        for document in iter(documents):
            # filter and return headings
            filtered.extend(
                filter_items(document.all_headings(), [contains_active_date]))
        return sorted(filtered)
示例#10
0
	def get_timestamped_items(self, documents):
		u"""
		Get all time-stamped items in a time-sorted way for the given
		documents (list of document).
		"""
		filtered = []
		for document in iter(documents):
			# filter and return headings
			filtered.extend(filter_items(document.all_headings(),
								[contains_active_date]))
		return sorted(filtered)
示例#11
0
	def get_next_week_and_active_todo(self, documents):
		u"""
		Get the agenda for next week for the given documents (list of
		document).
		"""
		filtered = []
		for document in iter(documents):
			# filter and return headings
			filtered.extend(filter_items(document.all_headings(),
								[is_within_week_and_active_todo]))
		return sorted(filtered)
示例#12
0
    def test_filter_items(self):
        # only headings with date and todo should be returned
        vim.command(
            u_encode(
                u"let g:org_todo_keywords = ['TODO', 'STARTED', '|', 'DONE']"))
        tmpdate = date.today()
        odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
        tmp_head = Heading(title=u'Refactor the code',
                           todo=u'TODO',
                           active_date=odate)
        tmp_head_01 = Heading(title=u'Refactor the code',
                              todo=u'STARTED',
                              active_date=odate)
        headings = [tmp_head, tmp_head_01]
        filtered = list(
            filter_items(headings,
                         [contains_active_date, contains_active_todo]))

        self.assertEqual(len(filtered), 2)
        self.assertEqual(filtered, headings)

        # try a longer list
        headings = headings * 3
        filtered = list(
            filter_items(headings,
                         [contains_active_date, contains_active_todo]))

        self.assertEqual(len(filtered), 6)
        self.assertEqual(filtered, headings)

        # date does not contain all needed fields thus gets ignored
        tmpdate = date.today()
        odate = OrgDate(True, tmpdate.year, tmpdate.month, tmpdate.day)
        tmp_head = Heading(title=u'Refactor the code', active_date=odate)
        headings = [tmp_head]
        filtered = list(
            filter_items(headings,
                         [contains_active_date, contains_active_todo]))
        self.assertEqual([], filtered)